insert pipe in the finish of the line


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users insert pipe in the finish of the line
# 1  
Old 04-03-2006
insert pipe in the finish of the line

hi,
i have a flat file, with lines (records), and fields, and each field is separated by pipe ( | ) :

1|078|012006|3,9
2|078|012006|8692275|4|2|GON3507090
2|078|012006|7655734|9|0|GON3507090
2|078|012006|7572405|5|4|GCR5N07090


what i need is to insert a pipe in the end of the line:
1|078|012006|3,9|
2|078|012006|8692275|4|2|GON3507090|
2|078|012006|7655734|9|0|GON3507090|
2|078|012006|7572405|5|4|GCR5N07090|

is this posible? any idea please....thanks...
# 2  
Old 04-03-2006
Code:
sed 's#$#|#' myFile.txt

# 3  
Old 04-04-2006
awk solution

Quote:
awk '{print $0"|"}' myFile.txt
# 4  
Old 04-04-2006
A solution that would not require the output to be redirected to some other file:
Code:
$ cat testfile
1|078|012006|3,9
2|078|012006|8692275|4|2|GON3507090
2|078|012006|7655734|9|0|GON3507090
2|078|012006|7572405|5|4|GCR5N07090
$ ex testfile <<!
> %s/$/|/g
> wq
> !
$ cat testfile
1|078|012006|3,9|
2|078|012006|8692275|4|2|GON3507090|
2|078|012006|7655734|9|0|GON3507090|
2|078|012006|7572405|5|4|GCR5N07090|

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert empty columns inside a pipe delimited file

Hi All , I have pipe delimiter file with 11 columns . I need to insert 4 empty columns after column 10 . and After 11 column I need to insert a column which is having the same value for all the rows . My file 1|2|3|4|5|6|7|8|9|10|11 New file ... (11 Replies)
Discussion started by: Hypesslearner
11 Replies

2. Shell Programming and Scripting

How to read a text file line by line and insert into a database table?

I have a test file that I want to read and insert only certain lines into the the table based on a filter. 1. Rread the log file 12 Hours back Getdate() -12 Hours 2. Extract the following information on for lines that say "DUMP is complete" A. Date B. Database Name C.... (2 Replies)
Discussion started by: JolietJake
2 Replies

3. Shell Programming and Scripting

sed command to replace a line in a file using line number from the output of a pipe.

Sed command to replace a line in a file using line number from the output of a pipe. Is it possible to replace a whole line piped from someother command into a file at paritcular line... here is some basic execution flow.. the line number is 412 lineNo=412 Now i have a line... (1 Reply)
Discussion started by: vivek d r
1 Replies

4. Shell Programming and Scripting

Insert a value in a pipe delimited line (unsig sed,awk)

Hi, I want to insert a value (x) in the 3rd position of each line in a file like below a|b|c|d|1 a|b|c|d a|b|c|d|e|1 a|b|cso that output file looks like a|b|x|c|d|1 a|b|x|c|d a|b|x|c|d|e|1 a|b|x|cI can do that using perl as below #!/usr/bin/perl -w use strict; #inserting x at... (5 Replies)
Discussion started by: sam05121988
5 Replies

5. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

6. Shell Programming and Scripting

how to Insert values in multiple lines(records) within a pipe delimited text file in specific cols

this is Korn shell unix. The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
Discussion started by: vasan2815
4 Replies

7. Shell Programming and Scripting

Print pipe separated list as line by line in Korn Shell

Korn Shell in AIX 6.1 I want to print the below shown pipe (|) separated list line by line. line=es349889|nhb882309|ts00293|snh03524|bg578835|bg37900|rnh00297|py882201|sg175883 for i in line do echo "Hello $line " done I wanted to execute the above for loop. But i can't even set the... (3 Replies)
Discussion started by: polavan
3 Replies

8. Shell Programming and Scripting

How to insert a sequence number column inside a pipe delimited csv file using shell scripting?

Hi All, I need a shell script which could insert a sequence number column inside a dat file(pipe delimited). I have the dat file similar to the one as shown below.. |A|B|C||D|E |F|G|H||I|J |K|L|M||N|O |P|Q|R||S|T As shown above, the column 4 is currently blank and i need to insert sequence... (5 Replies)
Discussion started by: nithins007
5 Replies

9. UNIX for Advanced & Expert Users

insert pipe in file to separate values

hi all... i need your help, because i donīt know what to do... i have a flat file like this: B065200512312004123111010000061451 000021853 B065200512312004123111020000621907 000417802 B065200512312004123111030000005214 000005861 B065200512312004123111040000120133 000088448 and i need... (5 Replies)
Discussion started by: DebianJ
5 Replies

10. Shell Programming and Scripting

using tab to finish command line parameter

Anyone know how to set it up so that when at command line in unix (specifically solaris 2.5.1), and you hit the tab it will finish the command with the nearest file that matches? AND how to set it up so using up and down arrows access your previous commands? Thanks for all the help here, i've had... (3 Replies)
Discussion started by: kymberm
3 Replies
Login or Register to Ask a Question