|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Formatting the file using pattern
Hi, Please suggest the suitable command for my below requirement. I have a file with greater than symbol (>) in many places in a file. For example, Code:
abcd>drfg>gdh i want the output file like, Code:
abcd> drfg> gdh> Please suggest. Thanks. Last edited by vbe; 02-15-2013 at 10:40 AM.. Reason: code tags please for your data or code |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
With GNU/Posix awk, linefeed after each ">" Code:
awk 'BEGIN {FS=">"; OFS=FS RS} NF>1 {$1=$1} 1' fileAdding an extra ">" Code:
awk 'BEGIN {FS=">"; OFS=FS RS} NF>1 {$NF=$NF FS} 1' fileLast edited by MadeInGermany; 02-15-2013 at 12:47 PM.. |
| The Following User Says Thank You to MadeInGermany For This Useful Post: | ||
rbalaj16 (02-15-2013) | ||
|
#4
|
|||
|
|||
|
Thanks all. it works fine.
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
In sed, very simple (but extra linefeed for > at end of line): Code:
sed 's/>/>\ /g' |
| The Following User Says Thank You to DGPickett For This Useful Post: | ||
MadeInGermany (02-16-2013) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search for a pattern in a String file and count the occurance of each pattern | swayam123 | Shell Programming and Scripting | 4 | 11-06-2012 02:27 AM |
| Formatting file data to another file (control character related) | hk6279 | Shell Programming and Scripting | 3 | 09-24-2012 03:17 AM |
| AWK match $1 $2 pattern in file 1 to $1 $2 pattern in file2 | right_coaster | Shell Programming and Scripting | 9 | 10-06-2011 11:54 AM |
| Searching a pattern in file and deleting th ewhole line containing the pattern | Shazin | Shell Programming and Scripting | 1 | 07-24-2009 11:27 AM |
| Search file for pattern and grab some lines before pattern | frustrated1 | Shell Programming and Scripting | 2 | 12-22-2005 02:41 PM |
|
|