![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| charecter or number | ganapati | UNIX for Dummies Questions & Answers | 1 | 01-02-2008 08:44 AM |
| Cutting a tab delimiter file | vinod.thayil | Shell Programming and Scripting | 4 | 11-30-2007 03:38 PM |
| Cutting Columns and Moving in to a file | Serious Sam | Shell Programming and Scripting | 3 | 10-22-2007 06:56 AM |
| Comapring files charecter by charecter using AWK/Shell Script | evvander | Shell Programming and Scripting | 1 | 09-12-2007 05:44 AM |
| cut First charecter in any string | rinku | Shell Programming and Scripting | 6 | 05-29-2007 07:23 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
cutting columns if delimiter has more than one charecter
Hi,
My file looks like abc$%sdfhs$%sdf$%sdfaf$% here as seen delimiter is $%...now how cas i take out second field as cut command expect delimiter as single charecter only.....is there is any other way thanks and regards mahabunta |
|
||||
|
Hmm, that didn't work in my test. Passing more than one character to -F just returned the entire line as argument $1.
Code:
awk -F"\$%" '{print $1}' file
abc$%sdfhs$%sdf$%sdfaf$%
abc$%sdfhs$%sdf$%sdfaf$%
abc$%sdfhs$%sdf$%sdfaf$%
abc$%sdfhs$%sdf$%sdfaf$%
abc$%sdfhs$%sdf$%sdfaf$%
abc$%sdfhs$%sdf$%sdfaf$%
abc$%sdfhs$%sdf$%sdfaf$%
Code:
sed -e "s/\$%/:/g" file | cut -f3 -d: sdf sdf sdf sdf sdf sdf Code:
cat files | tr -s "$%" ":" | cut -f3 -d: sdf sdf sdf sdf sdf sdf Code:
awk -F", " '{print $2}' files2
sdfhs
sdfhs
sdfhs
sdfhs
sdfhs
sdfhs
Carl |
|
||||
|
Quote:
Code:
>>> line = "abc$%sdfhs$%sdf$%sdfaf$%"
>>> secondfield = line.split("$%")[1] #element 1 is second field
>>> print secondfield
sdfhs
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|