A file named "months" contains the following content:
January
February
March
April
May
June
August
September
November
December
$ sed -i '7i\July' months
- This command will insert the month "July" on the 7th line
of the file,
Note: The word "July" is actually added to the file, on the 7th line!
Question: Any idea how to go about inserting "October" between
"September" and "November", without making reference to the
line number?
Note: This question is open to Chetan_Tiwary-level and below!
So, one can achieve the same objective by using this command as well :
sed -i '/September/a\October' months
a is for append the text October after the matched text pattern September.
@Trevor LOL there is a new level unlocked with my name :xD :
By using this command you can achieve the objecive :
sed -i '/November/i\October' months
this expression : /November/i\October : tells sed to search for the text November and insert before it ( i\ ) the text October in the months file.
So, one can achieve the same objective by using this command as well :
sed -i '/September/a\October' months
a is for append the text October after the matched text pattern September.
The highest Red Hat certification level is based on
Chetan_Tiwary_
RHCA (Red Hat Chetan Accolade)
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.