SED programming


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED programming
# 1  
Old 10-22-2010
SED programming

Hi Folks,

I have one file which contains the data like below.

gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%

I want to replace % to the Line feed. I mean the result should be like below.

gggsdvrwdtydjnnc
vhdskl;jf;whjfuyijfnv,m
jkgsjkfsjkjdlkl
gjksdhfljkfjkj

Can anyone help me how to do this using SED in IBM AIX?

Thanks a lot!!!!
# 2  
Old 10-22-2010
Code:
$ echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | ruby -pe 'gsub("%","\n")'

# 3  
Old 10-22-2010
Quote:
Originally Posted by kurumi
Code:
$ echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | ruby -pe 'gsub("%","\n")'

Hi

I am using AIX Version 5.2 ML5.

Ruby is not working in this version.

Code:
/download/pradeesh>echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | ruby -pe 'gsub("%","\n")'
ksh: ruby:  not found.



---------- Post updated at 11:07 PM ---------- Previous update was at 10:56 PM ----------




I found a new way to do this

Code:
/download/pradeesh>echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | tr '%' '\n'
gggsdvrwdtydjnnc
vhdskl;jf;whjfuyijfnv,m
jkgsjkfsjkjdlkl
gjksdhfljkfjkj

But I would like to know how to do this using SED. Can anyone help me??
# 4  
Old 10-22-2010
MySQL SED programming

Code:
echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | sed 's/\%/\n/g'

Try this...Smilie

output:
Code:
gggsdvrwdtydjnnc
vhdskl;jf;whjfuyijfnv,m
jkgsjkfsjkjdlkl
gjksdhfljkfjkj

# 5  
Old 10-22-2010
Hi Kesavan.

thanks for your reply but this is not working

Please check the below output. this is replacing % to n

Code:
apdma501:/dwfs/download/pradeesh>echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | sed 's/\%/\n/g'
gggsdvrwdtydjnncnvhdskl;jf;whjfuyijfnv,mnjkgsjkfsjkjdlklngjksdhfljkfjkjn

# 6  
Old 10-22-2010
MySQL SED programming

Quote:
Originally Posted by pradeesh
Hi Kesavan.

thanks for your reply but this is not working

Please check the below output. this is replacing % to n

Code:
apdma501:/dwfs/download/pradeesh>echo "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%" | sed 's/\%/\n/g'
gggsdvrwdtydjnncnvhdskl;jf;whjfuyijfnv,mnjkgsjkfsjkjdlklngjksdhfljkfjkjn

try giving
Code:
 echo  "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%"  | sed 's/\%/\\n/g'

Smilie
# 7  
Old 10-22-2010
Quote:
Originally Posted by Kesavan
try giving
Code:
 echo  "gggsdvrwdtydjnnc%vhdskl;jf;whjfuyijfnv,m%jkgsjkfsjkjdlkl%gjksdhfljkfjkj%"  | sed 's/\%/\\n/g'

Smilie
Tried all possibilities but its not working.. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C Programming

Is there any way to find the variables declared or defined in a c program and print those variables?? plz help (15 Replies)
Discussion started by: zinat
15 Replies

2. UNIX for Dummies Questions & Answers

From iOS programming to Linux system programming

Hello. I like Linux and C programming language. Allways wanted to understand kernel and become a Linux system programmer. And I also like Objective-C and iOS. These two programming areas have relations: 1. Linux and iOS are UNIX-like systems, POSIX compliant. 2. It is useful to know C language... (2 Replies)
Discussion started by: Rockatansky
2 Replies

3. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

4. Shell Programming and Scripting

Sh programming

I have started writing one script. It is not taking the if block. Here is the script: #!/bin/sh set USER='/usr/ucb/whoami' ####################################################################### #Killing Process #######################################################################... (6 Replies)
Discussion started by: amarpreetka
6 Replies

5. Programming

C Programming - Hardware Programming

Can someone help me on suggesting some ways to access the memory content in RAM directly from C/C++ source code. Please provide me any book name or any URL so that I can get an exhaustive knowledge over it. If possible please give me some tips on interacting with hardwares directly through... (3 Replies)
Discussion started by: nandumishra
3 Replies

6. Shell Programming and Scripting

Sed & awk programming

Hi all, can anyone have sed & awk programming doc..so that to learn it easier.. (1 Reply)
Discussion started by: gk2009
1 Replies

7. UNIX for Dummies Questions & Answers

Carreer:Networking Programming in Unix (C programming Language)

Hello, I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies

8. Shell Programming and Scripting

Sed issue in K Shell programming

I am doing the following script in k shell sed -i 's/FILENAME/$i/g' TEST/test$j.ctl > TEST/control$j.ctl In the file it replaces $i for all FILENAME, it doesnot replace with the value of i. I put single quotes like below sed -i 's/FILENAME/'$i'/g' TEST/test$j.ctl > TEST/control$j.ctl I... (9 Replies)
Discussion started by: toshidas2000
9 Replies

9. Shell Programming and Scripting

Unix Systems Programming Vs Unix Programming

Several months ago I found a link that explained the difference between how a Unix Systems Admin would do scripting compared to what a Unix Programmer would do. It showed a basic script and then show several iterations that explained how the Systems Admin would change it to make it better. I was... (0 Replies)
Discussion started by: BCarlson
0 Replies

10. Programming

c programming or unix programming!?

i would like advice on the usbject of c programming (in the middle of reading a book on C). could i benefit more if i apply that knowledge in the unix format if i were able to, or would that take the point out of learning C, basically I want to stay away from strying too far away from unix and use... (1 Reply)
Discussion started by: moxxx68
1 Replies
Login or Register to Ask a Question