|
|||||||
| 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
|
|||
|
|||
|
Each line dilimited by ; in output
HI, I am having a file as under : Code:
A3/APT "ABCDEFG" 789 120612 1501 BLOCK SUPER R LVB NDV BLO W2JO 10 680 20 I am using the under-noted script to get the outpur as under : Code:
awk '/^A...P.|^O/ {if(b) print b;b=$0;next} NF {b=b$0" "} END {print b}' myfile
A3/APT "ABCDEFG" 789 120612 1501 BLOCK SUPER R LVB NDV BLO W2JO 10 680 20I wanted to get the output each line delimited by ";" as under : Code:
A3/APT "ABCDEFG" 789 120612 1501; BLOCK SUPER; R LVB NDV BLO; W2JO 10 680 20 Please suggest. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
tr '\n' ';' < file | cat - <(echo) |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks! But it did not succeeded in my case.
![]() |
|
#4
|
|||
|
|||
|
Well, I agree wuth bartus11 though.... Code:
$ cat vanand420 3/APT "ABCDEFG" 789 120612 1501 BLOCK SUPER R LVB NDV BLO W2JO 10 680 20 Code:
$ cat vanand420 | tr '\n' ';' 3/APT "ABCDEFG" 789 120612 1501;BLOCK SUPER;R LVB NDV BLO;W2JO 10 680 20; |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks..might be shell issue. I am using bash on CYGWIN.
|
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Uhm... strange. And what did happen? However, try also this alternative: Code:
mapfile -t line <myfile; for i in ${!line[@]}; do echo -n "${line[$i]};"; done; echo |
| The Following User Says Thank You to Lem For This Useful Post: | ||
vanand420 (06-17-2012) | ||
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
@vanand420 Please post what you typed and what output was produced. Also please highlight what went wrong. I can see that a trailing semi-colon might be a problem as might be the absence of any line terminator after conversion. Just in case: 99% of all text file processing problems on Cywin are caused because a text data file contains Microsoft line terminators (carriage_return line-feed) not unix line terminators (line_feed). Please post the output from this enquiry on your input data file: Code:
sed -n l filename A line terminator displayed as just a Dollar Sign is normal for unix. |
| 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 |
| Joining multi-line output to a single line in a group | gvk25 | Shell Programming and Scripting | 7 | 03-07-2012 05:22 AM |
| Bash - Loading a command's output line by line into an array | Azrael | Shell Programming and Scripting | 4 | 09-20-2011 04:42 AM |
| Converting line output to column based output | npatwardhan | Shell Programming and Scripting | 8 | 03-24-2010 09:40 AM |
| how to make a line BLINKING in output and also how to increase font size in output | mail2sant | Shell Programming and Scripting | 3 | 04-14-2008 07:30 AM |
|
|