addition of the pipe in file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting addition of the pipe in file
# 1  
Old 06-30-2010
addition of the pipe in file

Hi All,

I have file on AIX server CBICD312.1.2010-06-14-06.log and its cotent is


Code:
[2010-06-14 06:14:08,849][Thread:WebContainer : 1[INFO]|ID~SLV3.1|CHANNEL_CODE~OHCC|FUNC_REC_TYPE~OHCE-5603|LOCAL_TIMESTAMP~2010-06-14-06.14.08.000008|LOCAL_TIMEZONE~GMT|CUST_UNIQUE_ID~1600159508|EVENT_ENTITY_CODE~HBTH|LOCATION_CODE~|EVENT_ID~OHCE-0019|EVENT_ERROR_CODE~|SESSIONID~sjfTp2xhplTz0n-R3XlBA9X|BUFFER1~|BUFFER2~|BUFFER3~|AGENT_ID~OHD13023|DNIS~|IVR_REF_NO~|CALL_TYPE~|CHANNEL_BUFFER5~|CHANNEL_BUFFER6~|CHANNEL_BUFFER7~|CHANNEL_BUFFER8~|CHANNEL_BUFFER9~|CHANNEL_BUFFER10~|CONTACT_ID~CriIgHd8Ed+uRgAMKeEGSQ==|JRNY_INST_ID~ViaeKfepAaFAYSMyTtIL|

This file is pipe seperated and i want to add one pipe on every before LOCAL_TIMESTAMP~ like this

Code:
[2010-06-14 06:14:08,849][Thread:WebContainer : 1[INFO]|ID~SLV3.1|CHANNEL_CODE~OHCC|FUNC_REC_TYPE~OHCE-5603||LOCAL_TIMESTAMP~2010-06-14-06.14.08.000008|

Can anyone help me to develop the script for this?

can it be done with awk and array..??

Please reply me.

Thanks

Last edited by radoulov; 06-30-2010 at 11:14 AM.. Reason: Code tags, please!
# 2  
Old 06-30-2010
Code:
awk '{gsub("LOCAL_TIMESTAMP~","|LOCAL_TIMESTAMP~");print}' file

# 3  
Old 06-30-2010
Code:
sed 's/\(\|LOCAL_TIMESTAMP\)/\|\1/g' file

# 4  
Old 06-30-2010
Thanks a lot for your immediate reply...it works....Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sort file using pipe

I am trying to create a file (epilepsy70_average.txt) and then pipe that file into a sort and save a new file. The new file is sort.txt but as of know it is blank. I can create the file in one command and then sort it in another. Is the pipe not correct? Thank you :). awk... (2 Replies)
Discussion started by: cmccabe
2 Replies

2. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

3. Shell Programming and Scripting

How to ignore Pipe in Pipe delimited file?

Hi guys, I need to know how i can ignore Pipe '|' if Pipe is coming as a column in Pipe delimited file for eg: file 1: xx|yy|"xyz|zzz"|zzz|12... using below awk command awk 'BEGIN {FS=OFS="|" } print $3 i would get xyz But i want as : xyz|zzz to consider as whole column... (13 Replies)
Discussion started by: rohit_shinez
13 Replies

4. UNIX for Dummies Questions & Answers

Pipe binary file matches grep results to file

I am using grep to match a pattern, but the output is strange. $ grep -r -o "pattern" * Gives me: Binary file foo1 matches Binary file foo2 matches Binary file foo3 matches To find the lines before/after, I then have to use the following on each file: $ strings foo1 | grep -A1 -B1... (0 Replies)
Discussion started by: chipperuga
0 Replies

5. Shell Programming and Scripting

Convert CSV file (with double quoted strings) to pipe delimited file

Hi, could some help me convert CSV file (with double quoted strings) to pipe delimited file: here you go with the same data: 1,Friends,"$3.99 per 1,000 listings",8158here " 1,000 listings " should be a single field. Thanks, Ram (8 Replies)
Discussion started by: Ram.Math
8 Replies

6. Shell Programming and Scripting

Replace pipe with Broken Pipe

Hi All , Is there any way to replace the pipe ( | ) with the broken pipe (0xA6) in unix (1 Reply)
Discussion started by: saj
1 Replies

7. Shell Programming and Scripting

addition of text upper and lower end of file

Hello folks, I have a file that size is over 20GB. if i open in vi it takes ages. i want to add three lines at the top of file and three lines at the end of files. lines are as follows upper three lines 114444bbbbbb dddd4544d4cc rrrr4dddddddd5 at the end of file need to add three... (2 Replies)
Discussion started by: learnbash
2 Replies

8. Shell Programming and Scripting

Help with addition of 2 numbers that are read from a file

I am trying to add free and used memory (so that i can compute percentage used)of remote nodes using shell script. I use the openssh-server,expect tool and ssh script. 1)login.txt (info of nodes): ip1|username|password ip2|username|password . . . 3)sshlogin.sh #!/bin/bash ... (1 Reply)
Discussion started by: marmik1903
1 Replies

9. Shell Programming and Scripting

Script to Check & Edit Content of a file (Addition of comma in each lines of code)

Hi all, I need to write an automated bash shell script which performs such operations: 1. Grep the header of everyline with the initial of "T" in "FILE_A" 2. Perform a for loop, Count the numbers of comma in the line of code, if (no. of comma < 17) ADD the comma until 17; ... (2 Replies)
Discussion started by: big_nutz
2 Replies

10. Shell Programming and Scripting

Addition of all the numbers in a single file

Hi All , Want to know the "sum" of all the digits in below file called "/sample" .Could some one please let me know the script either command . cat /sample 12 34 23 23 Best Regards, Chinni . (5 Replies)
Discussion started by: chinni-script
5 Replies
Login or Register to Ask a Question