Skip to main content

Output of a command in a shell script

When you want to assign output of a shell command to a variable in your shell script, you have to write shell command between special quotation marks ` <command here> `

example: This command shows oldest two backups.
old_backups=`ls -td backup* | awk 'NR>2'`
echo $old_backups

Comments

Popular posts from this blog

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.