![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using grep to extract line number | mskarica | Shell Programming and Scripting | 8 | 06-25-2008 11:47 PM |
| extract field of characters after a specific pattern - using UNIX shell script | jansat | HP-UX | 2 | 05-27-2008 09:08 PM |
| need to extract field of characters in a line | jansat | Shell Programming and Scripting | 3 | 05-22-2008 06:44 AM |
| SED to extract characters | Shilpi | Shell Programming and Scripting | 1 | 08-03-2007 04:22 AM |
| SED to extract characters | Shilpi | Shell Programming and Scripting | 2 | 08-03-2007 04:02 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Grep and extract the characters after
Hi All,
I have lines like below in a file A /u/ab/test1.dat A/u/ab/test2.dat A /u/bb/test3.dat A/u/cc/test4.dat I will need /u/ab/test1.dat /u/ab/test2.dat /u/bb/test3.dat /u/cc/test4.dat Pls help Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
root@mp-wst01 # cat testfile A /u/ab/test1.dat A/u/ab/test2.dat A /u/bb/test3.dat A/u/cc/test4.dat root@mp-wst01 # cut -f"2" -d"A" < testfile | sed 's/ //' > newfile root@mp-wst01 # cat newfile /u/ab/test1.dat /u/ab/test2.dat /u/bb/test3.dat /u/cc/test4.dat root@mp-wst01 # |
|
#3
|
|||
|
|||
|
Code:
awk '{gsub(/^A\ */,"")}{print}' file
|
|
#4
|
|||
|
|||
|
I hope that you do not want the first character in your file, so below command would help you
Code:
cut -c2- file > newfile |
|
#5
|
|||
|
|||
|
Code:
sed "s/^A *//" filename |
|
#6
|
|||
|
|||
|
Code:
sed 's/^. *//' filename |
|
#7
|
||||
|
||||
|
Code:
sed 's!^[^/]*!!' filename |
||||
| Google The UNIX and Linux Forums |