Sponsored Content
Top Forums Shell Programming and Scripting sed Command new Line not working Tried many variations Post 302884272 by Akshay Hegde on Sunday 19th of January 2014 02:35:10 PM
Old 01-19-2014
Power

Try :
Code:
$ cat file
pwrm16: Info: Thu Dec 12 22:20:23 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. pwrm17: Info: Sun Dec 15 21:37:30 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. pwrm18: Info: Wed Dec 18 11:31:43 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. pwrm16: Info: Wed Dec 18 14:00:05 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. pwrm16: Info: Thu Jan 02 13:51:24 2014 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. pwrm19: Info: Fri Jan 17 01:16:26 2014 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. pwrm16: Info: Fri Jan 17 03:39:19 2014 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition.

Code:
$ awk 'gsub(host_prefix,"\n\n&")' host_prefix=pwrm  file


pwrm16: Info: Thu Dec 12 22:20:23 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. 

pwrm17: Info: Sun Dec 15 21:37:30 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. 

pwrm18: Info: Wed Dec 18 11:31:43 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. 

pwrm16: Info: Wed Dec 18 14:00:05 2013 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. 

pwrm16: Info: Thu Jan 02 13:51:24 2014 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. 

pwrm19: Info: Fri Jan 17 01:16:26 2014 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition. 

pwrm16: Info: Fri Jan 17 03:39:19 2014 User PWPYNYFWD01 at position 170.198.8.160/net on host 170.198.8.160 using application 257 has been disconnected due to an overflow condition.

Code:
$ awk 'gsub(host_prefix,"\n\n&")' host_prefix=pwrm <<<$Variable


Last edited by Akshay Hegde; 01-19-2014 at 03:47 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed to replace a line is not working

This is what I have this far rsh server1 "cat /home/test.txt |sed s/01-jun-2009/01-aug-2009/ |sed s/ABCD/1234/" but it is not working is there something I am doing wrong in my syntax? The file test.txt is the same on all of my 15 servers it has the same length and contents only certain... (3 Replies)
Discussion started by: deaconf19
3 Replies

2. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

3. Shell Programming and Scripting

Sed: Working on a line Previous to a pattern.

Hello everyone, I am working with some train time tables, and i have hit a bit of a road block. Using grep/sed i have done a reasonable job of parsing the html into comma delimited format, but NJ transit prints The Track number and status on a new line, and I would much prefer it all on a... (6 Replies)
Discussion started by: mussen
6 Replies

4. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

5. Shell Programming and Scripting

sed adding a new line not working

The file which is used is /abc/apps/cobbbbbb/apps/abadv/binder/axyz.bnd /abc/apps/cobbbbbb/apps/abbrio/binder/na6115.bnd /abc/apps/cobbbbbb/apps/abbrio/binder/kc22.bnd /abc/apps/cobbbbbb/apps/abbrio/binder/tr4823.bnd /abc/apps/cobbbbbb/apps/abcmp/binder/cpc0105.bnd The commads which I ran... (3 Replies)
Discussion started by: bhavanabahety
3 Replies

6. Shell Programming and Scripting

sed adding a new line not working

sed '/patternstring/ a\ new line string' file1 The above code is not working even with the i option.... it shows sed grambled if '\' after new line string is not being used....after using no changes it is displaying..Pls help (5 Replies)
Discussion started by: bhavanabahety
5 Replies

7. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies

8. Shell Programming and Scripting

sed working on command line but file unchanged when execute with Shell script

I have a simple task to replace unix line feed end of line characters with carriage returns. When I run the following “change file in place” sed instruction from the command line all the Line feeds are successfully replaced with Carriage returns. sed -i 's/$/\r/' lf_file.txt But that same... (1 Reply)
Discussion started by: hawkman2k
1 Replies

9. Shell Programming and Scripting

sed command not working

cat bipin.txt Unix is an OS Unix has its own commmands Unix is a user friendly OS Unix is platform independent Unix is a time sharing OS the best OS to learn is Unix Abinitio uses Unix in backend this is my file when i use sed 's/Unix/Linux/' bipin.txt all the occurences are getting... (0 Replies)
Discussion started by: Bipin_1991
0 Replies

10. Shell Programming and Scripting

Remove matching pattern on each line with number variations

Hello folks! I have a file containing lines like this Something text 18:37Remove This: 1,111"Keep this text" Some more text 19:37Remove This: 222"Keep this text" More text 20:50Remove This: 3,333Keep this text And more text 25:50Remove This: 44,444Keep this text I would like to... (4 Replies)
Discussion started by: martinsmith
4 Replies
All times are GMT -4. The time now is 10:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy