Mrdogkick
asked on
simple problem i think...
I have written the following script which should find all the occurences of a particular user in the xx file and print them to an other file (user). This all work and my output looks like this:
1 OLDPWD=/home/hussain.ahmed
2 USER=hussain.ahmed
3 MAIL=/var/spool/mail/hussa in.ahmed
Something very annoying but I want each line number to have a bracket after it. ie
1)........
2)..............
etc.
Any ideas??
1 OLDPWD=/home/hussain.ahmed
2 USER=hussain.ahmed
3 MAIL=/var/spool/mail/hussa
Something very annoying but I want each line number to have a bracket after it. ie
1)........
2)..............
etc.
Any ideas??
#!/bin/bash
file=/home/hussain.ahmed/coursework/chapter7/xx
grep $USER $file | nl >/home/hussain.ahmed/coursework/chapter7/user
ASKER
isn't there a way I could say 'cut into the first space of each line and add a ")"'?
Well, I am not sure if there is simple command that can give you this.
Did you try yhe solution?
Did you try yhe solution?
grep $USER $file | sed = | paste -s -d ')\n' - -
Sorry I put sed in the wrong place. Please try
#!/bin/bash
file=/home/hussain.ahmed/c
grep $USER $file | nl | sed s/\ /\)\ / > /home/hussain.ahmed/course
ASKER
I am actually trying to do this without the use of sed or AWK? any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
#!/bin/bash
file=/home/hussain.ahmed/c
grep $USER $file | nl >/home/hussain.ahmed/cours