38. whereis command examples When you want to find out where a specific Unix command exists (for example, where does ls command exists?), you can execute the following command. $ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz 1. 2. When you...
When you copy a DOS file to Unix, you could find \r\n in the end of each line. This example converts the DOS file format to Unix file format using sed command. $sed 's/.$//' filename Print file content in reverse order $ sed -n '1!G;h;$p' thegeekstuff.txt Add line numb...
2. grep command examples Search for a given string in a file (case in-sensitive search). $ grep -i "the" demo_file Print the matched line, along with the 3 lines after it. $ grep -A 3 -i "example" demo_text Search for a given string in all files recursively $ grep -r "rames...
On saving the file the command will be run. How to view when commands were run¶ For thezshshell it is possible to see when commands were run by passing the-doption to show the timestamp for each command. In the following example the-loptions is also passed to only list commands. ...
This command uses : as the field separator to extract the first field (username) from the /etc/passwd file. 6. Can awk be used with conditions? Yes, awk allows users to apply conditions for pattern matching and executing specific actions based on those conditions. For example: ...
How to use tail with pipes The tail command can be piped to from other commands. In the following example the output of the ls command is piped to tail to only show the five files or folders modified the longest time ago.ls -t /etc | tail -n 5 login.defs request-key.conf libao....
Following is a sample of ls -l command output. In this, the 9 characters from 2nd to 10th position represents the permissions for the 3 types of users. -rw-r--r-- 1 john john 272 Mar 17 08:22 test.txt In the above example: ...
In unix, the command (as an example)... tail -5 /etc/passwd ...will print the last 5 lines of the /etc/passwd file the command (as an example)... head -2 /etc/passwd will print the first two lines of the /etc/passwd file ...
Edquota command is used to edit the quotas for a user or group. This is just an editor, from where you can change the quota values. By default, this will open up the quota file in an Vi editor, from where you can change the values. When you save the file, it will overwrite the ...
Common usages of tar command: How to create a tar file ? Syntax: # tar -cf archive.tar files .. .. Example: [root@localhost TAR]# tar -cf file.tar file1.txt file2.txt [root@localhost TAR]# ll file.tar -rw-r--r--. 1 root root 10240 Feb 7 22:42 file.tar ...