Hi I would appreciate your help with this.
I have a output file from a command. It is broken based on initial of the users. Exmaple of iitials MN & SS. Under each section there is information pertaining to the user however each section can have different number of lines. MY challenge is to
Grep for a particular initials ( Example MN ) and print all the lines under this initial
and put them in to a new file. The problem is that uder each initial there could be any number of lines. So the number of lines per initial is not fixed. How can I do this? I put sample of input and output files.
RS is record separator, when it is blank an empty line is used a the record separator ORS it the output record separator "\n\n" causes the output to also have a blank line (two newline chars) between records
Can anyone please let me know how to achieve the below output.
My input file is like :
[Name1]
Address=abc
mob=1234
[Name2]
Address=bcd
mob=5678
Now from command line i need to supply [Name1] or [Name2] and according to that my i want the output. That means if input is [Name1] than output will be :
Address=abc
mob=1234
I have used the below commands :
awk '$1=="[Name1]"' ORS="\n\n" RS= input_file.txt
But when i am trying the below mentioned steps than I am not getting the output.
#!/bin/sh