Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

redirecting

  • 20-08-2007 08:16PM
    #1
    Closed Accounts Posts: 91 ✭✭


    "Obtain a list of users from the /etc/passwd file, sort it and then redirect it to a new file called ‘users’."

    cat passwd | cut -d: -f5 | sort > users


    Ok but i want to redirect it to coursework/chapter5/users

    and i get an error saying no such file or directory.

    anyone any ideas?


Comments

  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    magnia wrote:
    cat passwd

    This is the problem. You're saying "output the contents of the file 'passwd' ". There isn't one in the directory you're in. What you want is:

    cat /etc/passwd

    and redirect to is:

    > coursework/chapter5/users

    at the end (unless you're already in that directory of course).


  • Closed Accounts Posts: 91 ✭✭magnia


    yeah i am in that directory and i want to redirect to the coursework directory but cant

    im here /etc


  • Registered Users, Registered Users 2 Posts: 304 ✭✭PhantomBeaker


    So when you do
    cat passwd | cut -d: -f5 | sort > coursework/chapter5/users
    

    if you're in /etc, you're redirecting to /etc/coursework/chapter5/users - and I'm assuming /etc/coursework or /etc/coursework/chapter5 doesn't exist.

    The problem is, you're using relative paths - they depend on the directory you're sitting in. Try using absolute ones (ones that will get you to the same place regardless of the directory you're currently in).

    Hint: these pathnames start with /

    Aoife


Advertisement