0% found this document useful (0 votes)
4 views

Unix Commands-1 (1)

The document provides a comprehensive list of command-line commands along with their uses, covering various functionalities such as file and directory management, text editing, and data processing using tools like AWK, SED, and grep. It includes commands for creating, removing, copying, and moving files, as well as searching and manipulating text within files. Additionally, it highlights specific command options and examples to illustrate their applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Unix Commands-1 (1)

The document provides a comprehensive list of command-line commands along with their uses, covering various functionalities such as file and directory management, text editing, and data processing using tools like AWK, SED, and grep. It includes commands for creating, removing, copying, and moving files, as well as searching and manipulating text within files. Additionally, it highlights specific command options and examples to illustrate their applications.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Commands Uses

mkdir To create a new directory


mkdir -p For creating multiple dirs
cd Change directory
cd ../../ Previous directory
pwd present working directory
gvim (file name) To create a new file
rm -rf To remove directory
rm To remove file
cp To copy the flie
cp -rf to copy the directory
ls showing the list of files
ll
to get the all the files and details with time and date
ls -lrt
ctr+l to clear all
History to get all details what we done
:set nu to give the number
:set no nu removing the numbering
/Error/ to highlight errors
n next error
:v//d deletes all expert highlighted one
:g//d deletes selected one
Shift+n previous error
Shift+g go to the end line
gg go to the first line
dd deleting the line
10dd deletes 10 lines
u go to the previous line
home go to the starting line
end go to the end line
:q to quit
:q! hardly quit
:w to save
esc+:+qw save and Quit
:w! hardly save
Ctrl +v+selected+shift i+shift # esc To comment the files
:!g/ERROR/d separates error
gvim ~/.aliases to edit aliases
vslipt In file (to open file side by side)
ctrl +v+select+delete To remove comment files
shift * To select the any word to highlight that word
mv (file name required file name) To move the file
gvim file 1 file 2 -p To open two files at time
:sp open file at top and bottom
:vsp open file side by side
ls or ll or ls-lrt list of files or directories
: %s/bin/tin/g to replace bin by tin
gvim file 1 file 2 -d To open two different files path
ctrl +shift +n To open new terminal
ctrl+shift+t To open new separate terminal side by side
kill - 9 (job id) To kill
du -sh * It will show the space of the disk
df -kh . it will show the each data
:w <filename> creates new file
:%s//name /gc To replace highlight one
:%s/\\r/gc To get all the lines in single row
:%!grep "start point" w <file name>
:%s/^/select INST/g To add at starting position in a line
:%s/$/}/g To add at ending position in a line
? highlight the word
less sort.rpt | sort -nk 2 | less for printing 2 column in descending order

AWK Uses
awk '{print $2}' print second coloum
awk '{print $2 $4}' print second coloum and fourth coloum
awk '{print $NF}' print only last line
awk '{print $NR}' just only give number
awk '{print NR,$0}'
awk'{for(i=1;i<=NF;i++)print $i}' printing each field in row in new line
awk 'BEGIN {print"hi"}{print $1} BEGIN keyword used to before parsing all the lines
awk'{print$1}END{print"bye"}' END key word is used after parsing all the lines
awk '{sum+=$1}END{print sum}' adding values
awk 'NF>=4' print all lines having greater than four fields
awk'/rdt_done/{print $1}' sample.rpt awk can serve the purpose of grep

SED Uses
sed 's/foo/bar/' substitute (find and replace )the first occurrence of "foo" with "bar" on each line
sed 's/foo/bar/2' substitute (find and replace) the second occurrence of ''foo with "bar" on each line .
sed 's/foo/bar/g' substitute (find and replace ) all occurrence of "foo" with "bar" on each line
sed '/baz/s/foo/bar/g' Substitute all occurrences of "foo" with "bar" on all lines that contain "baz".
sed '/baz/!s/foo/bar/g' Substitute all occurrences of "foo" with "bar" on all lines that DO NOT contain "baz".
sed 's/scarlet\|ruby\|puce/red/g' replacing multiple patterns with one pattern
sed 's/^[ \t]*//;s/[ \t]*$//' Delete both leading and trailing whitespace from each line.
sed -e 's/^[ \t]*//’ -e ‘s/[ \t]*$//' Delete both leading and trailing whitespace from each line.
sed '/PATTERN-1/,/PATTERN-2/d' delete all the lines between 2 patterns
sed -i -e '/PATTERN-1/,/PATTERN-2/{s/^/#/g}' between 2 patterns using search and replace

grep Uses
grep ‘pattern' filename
grep 'Design' -A1 timing.rpt returns pattern match and 1 line after the pattern
grep 'Design' -B1 timing.rpt returns pattern match and 1 line before the pattern
grep 'Design' -C1 timing.rpt returns pattern match and 1 line after the pattern & 1 line before the pattern
grep 'Design\|Version' -A1 timing.rpt
grep -E 'Design|Version' -A1 timing.rpt egrep 'Design\|Version' -A1 timing.rpt
egrep 'Design\|Version' -A1 timing.rpt
grep -i 'design' -A1 timing.rpt ignore case
grep -v 'Startpoint' timing.rpt return all lines except match
grep -o 'Startpoint' timing.rpt return only matching pattern excluding lines
grep -l 'Startpoint' ./* return file names having pattern
grep -c 'Startpoint' timing.rpt return total count of matches
grep --color 'Startpoint' timing.rpt colouring the matching pattern
grep -n 'Startpoint' timing.rpt return with line numbers
grep -m2 'Startpoint' timing.rpt stop search after certain occurance
grep '[[:alnum:]]' timing.rpt all alphanumeric characters

Find Uses

You might also like