Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

theoretical question about bash and text

  • 24-08-2007 8:14pm
    #1
    Registered Users, Registered Users 2 Posts: 865 ✭✭✭


    so here's an issue I've finding it hard to get my head around, and google isn't helping

    I suppose I'd best point to it by saying that

    sort `ls`

    causes sort to output the contents of all files and alphabetise it

    whereas

    ls | sort

    causes sort to alphabetise the directory contents outputted by ls. I know sort takes a file as input usually, but when a the output of ls (a string?) is piped, it deals with that as if it were the output of a file given as an argument

    Am I missing something here? Is this just the difference between "echo" and "cat", or is this something to do with the way bash's own invisible pipes work (like wildcards operating before any program sees them, etc)

    Is this the same reason for this
    shanet@generalmiaow:~$ echo `cat foo`
    Now is the time for all good men to come to the aid of the party
    shanet@generalmiaow:~$ cat foo | echo

    shanet@generalmiaow:~$ cat foo | cat
    Now is the time for all good men to come to the aid of the party
    shanet@generalmiaow:~$

    I have been trying to figure this out for ages. I think it's something very fundamental but I can't find a good introduction to this notion


Comments

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


    Ok, this is essentially a question about backticks vs pipes.

    With backticks, it's basically saying "Run the command between the backticks and take it's output. Pretend I said that instead."

    so
    ping `hostname`
    

    would look up the output of what happens when "hostname" is run, and it would ping it. I.e. the output of hostname is given as a command-line parameter to ping.

    With pipes, using the '|' operator, it hooks up the output of the first program into the input of the next program. If you want more information on that, google either "RUTE" for a very good *nix tutorial (redhat linux heavy, but the commandline stuff will work anywhere), or google "redirection bash".

    Hint, the reason why "cat foo | echo" didn't work is because echo doesn't listen on its standard input (which has caused me no end of pain on occasion until I remembered that)

    Hope that helps,
    Aoife


  • Registered Users, Registered Users 2 Posts: 865 ✭✭✭generalmiaow


    Thanks Aoife, having a look at that tutorial now and it's great.


Advertisement