Skip to main content

Posts

Showing posts with the label Commands

Linux Commands

1. tar command examples Create a new tar archive.  $ tar cvf archive_name.tar dirname/   Extract from an existing tar archive.  $ tar xvf archive_name.tar View an existing tar archive.  $ tar tvf archive_name.tar 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 "ramesh" * 3. find command examples Find files using file-name ( case in-sensitve find) $ find -iname "MyCProgram.c"   Execute commands on files found by the find command $ find -iname "MyCProgram.c" -exec md5sum {} \;   Find all empty files in home directory $ find ~ -empty 4. awk command examples Remove duplicate lines using awk $ awk '!($0 in array) { array[$0]; print }' temp   Print all lines from /etc/passwd ...