![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk program to select a portion of a line | anju | Shell Programming and Scripting | 3 | 01-11-2008 06:33 AM |
| Cutting a tab delimiter file | vinod.thayil | Shell Programming and Scripting | 4 | 11-30-2007 03:38 PM |
| cutting columns if delimiter has more than one charecter | mahabunta | UNIX for Dummies Questions & Answers | 9 | 09-14-2006 09:23 AM |
| erasing portion of line with sed (only once) | gammaman | UNIX for Dummies Questions & Answers | 1 | 07-14-2005 09:40 PM |
| erasing portion of line with sed | gammaman | UNIX for Dummies Questions & Answers | 5 | 07-10-2005 11:47 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Cutting a portion of a line seperated by pipe delimiter
Hi,
In the below line a|b|10065353|tefe|rhraqs|135364|5347575 dgd|rg|4333|fhra|grhrt|46423|urdsgd Here i want to cut the characters in between the second and third pipe delimiter and then between fifth and sixth delimiter and retain the rest of the line. My output should be a|b||tefe|rhraqs||5347575 dgd|rg||fhra|grhrt||urdsgd How do i do this? |
|
||||
|
This there a way to do this using a cut command?
Because the columns to be cut will be there in another paramfile. I have fixed width file as well as pipe delimited file. In case of fixed width file i will read the position to be cut from the param file and use the below commands. This is done in a script. position=`grep "abc.txt" $path/paramfile | awk '{print$2}'` cut -c$position abc.txt > file2.txt Structure of param file will be like abc.txt 1-5,68- In case of delimited files if the same approach could be followed it would be easy.Because for each and every delimited file, the columns to be cut may vary.Hence i cannot hard the position to be cut in your code. In case the file is a delimited file then the param file will have the information of which columns have to be retained. like file2.txt 1,3,4,7- Last edited by ragavhere; 06-21-2008 at 05:46 AM.. Reason: Delimited file parm file structure |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|