Skip to main content

Posts

Showing posts with the label cat

File Commands

Redirecting output and piping Before we see file commands, let us see two operations which are quite useful. These are redirecting output (and input) and piping the output. We know that ls command lists the files in current directory. Can we save this listing to a file? Yes. That can be done using > - redirection operator. ls>a.txt redirects the output of ls command to a file called a.txt. Remember that is exactly how we created our file earlier - by redirecting output of cat command to a file. So what we see in screen shot is - output of echo command is redirected to cc.txt. And of course cc.txt has complete path information of our system. Next we pipe the output of echo $PATH  command to cat, so that it gets displayed. Piping is done using "|". It sends the output of a command as input to another command. So output of echo command is sent as input to cat. In the next line we are piping output of echo command to wc command. wc is word count c...

User commands in Ubuntu

Echo command echo command is not exactly related to users. But it just echoes whatever you type. So if you say echo hello - it will display that The first echo line just displays hello.  The second echo command displays my home directory. $HOME is an environment variable which stores current user's home directory. The third echo command displays another environment variable $PATH . PATH indicates path of executable files. Whenever you type some command, the executable file with this command name is searched in the directories given by PATH variable. If the command is not found in any of the paths specified, then we get an error message - command not found.  Now let us put these commands together in a text file and try to run the file. To create a file, we can use vi editor or GUI editor called gedit. Since I am running a web terminal in a windows system, I do not have access to GUI editor.  I use cat command instead. Cat command it displays t...