The user the script is running as probably does not have the root directory (i.e., '/') as part of its $PATH. Which means that, in order to refer to a file in the root directory, you must give it the absolute pathname. In the case of the root dir, this just means prepending the slash, so that 'scriptname' just becomes '/scriptname'
It's worth noting that the default setup for most Linux accounts does not include the current directory in the path, either, the way Windows does. This means that an absolute path must be used to execute a script from another script -- even if they're both in the same place. (This is considered a Good Thing for reasons of security, or so I am given to understand.)
If I'm misunderstanding the question I apologize, but I hope this helps.
EDIT: As for the second part, combining commands in the way you want, well, this is one of my favorite things about the command shell, and it illustrates one of the reasons that the Linux-based shells are often considered more full-featured than what's usually available on Windows. You can use what are called pipes to send the output of one command into the input of the another. To do this, you combine the commands with the pipe, or vertical bar, character - '|' In this case, try:
grep -w "asd" doc.data | sort -k2,2n | head -5
The commands sort
and head
are both pipe-compatible (as are most native commands where it makes sense). This means that they use "standard input" (STDIN) and "standard output" (STDOUT). STDOUT is, by default, printed to the screen. But that's what the pipe character does - it sends STDOUT instead to the next command's STDIN. Hope this makes sense, and is useful. Give it a shot!