Suppose you have have a parameter:-
env = “production” & in runtime you want to substitute this parameter $env in a string,
this is how it can be done :-
“This setup has been run on ${env} environment”
Suppose you have have a parameter:-
env = “production” & in runtime you want to substitute this parameter $env in a string,
this is how it can be done :-
“This setup has been run on ${env} environment”
Based on number of lines :-
split -l 200000 mybigfile.txt
Grep searches the named input FILEs (or standard input if no files are named, or the file name –is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.
More info can be seen at http://www.tutorialspoint.com/unix_commands/grep.htm
Eg : grep “STRING“ %pathtofile% | cut -d ‘“‘ -f2
Search for a string in a file , the “pipe” connects the stdout
of one command to the stdin
of another , cut with dlimiter ” and select the second term (-f2)
Tee command is used to store and view (both at the same time) the output of any other command.
Tee command writes to the STDOUT, and to a file at a time as shown in the examples below.
The following command displays output only on the screen (stdout).
$ ls
The following command writes the output only to the file and not to the screen.
$ ls > file
The following command (with the help of tee command) writes the output both to the screen (stdout) and to the file.
$ ls | tee file
You can also use tee command to store the output of a command to a file and redirect the same output as an input to another command.
The following command will take a backup of the crontab entries, and pass the crontab entries as an input to sed command which will do the substituion. After the substitution, it will be added as a new cron job.
$ crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab –
By default tee command overwrites the file. You can instruct tee command to append to the file using the option –a as shown below.
$ ls | tee –a file
You can also write the output to multiple files as shown below.
$ ls | tee file1 file2 file3
***********************************************************************************************************************************************************
Courtesy: http://linux.101hacks.com/