Linux Grep, Sed Commands - Tecnew

Home Ads

Linux Grep, Sed Commands

Linux Grep, Sed Commands

Share This

 




reating the link files 

ln -s /home/vagrant/data/tool.txt devtool It will create the softlink of the original file

unlink devtool         It unlinks the file

rm devtool                 It is also unlink the file


Filter by grep command

(grep word file)

grep what file name It means the what is the word contains the file it will searches

grep -i what file name It searches the word by case insensitively

grep -i what *.cfg It searches all files contains .cfg

grep -i what * It searches the all the files in current directory

  

less and more

less file name It shows the information by pressing the down arrow to go down up                                                         to go upwords and type q to quit

more file name It shows the information by pressing enter to go down and press q to quit


head and tail

head file name It shows 10 lines from starting

head -20 file name It shows 20 lines from starting

tail file name It shows 10 lines from ending

tail -20 file name It shows 20 lines from ending

tail -f file name It shows the dynamic content it updates in terminal


cut -d: -f1 file name Delimiters is used to shows the colums by separately


Search and replace by Vim editer


:%s/devops/noops/g It replaces the word devops by noops in vim editer

sed -i 's/devops/noops/g'         It replaces the word devops by noops


head -5 file name > /tmp/tool.txt It store the first five lines into tool.txt file

head -5 file name >> /tmp/tool.txt It store the first five lines into tool.txt and keeps the previous info



No comments:

Post a Comment