related to sed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers related to sed
# 1  
Old 01-17-2007
related to sed

hi
how can we change only the first ocurrence of a pattern using sed
thank u
# 2  
Old 01-18-2007
Code:
sed 's/search/replace/' file

# 3  
Old 01-18-2007
A more literal intrepretation of the question:
sed '-e /search/{s/search/replace/;:L' -e 'n;bL' -e'}'
# 4  
Old 01-18-2007
u can use

sed -e 's/^occurence/changepattern/g' file
# 5  
Old 01-18-2007
Quote:
Originally Posted by maheshwin
u can use

sed -e 's/^occurence/changepattern/g' file
This wont replace with changepattern if the search string is not at the start of the line.
# 6  
Old 01-18-2007
Quote:
Originally Posted by anbu23
This wont replace with changepattern if the search string is not at the start of the line.
yea u r right , this will change first character apperance,
# 7  
Old 01-18-2007
reply

Quote:
Originally Posted by matrixmadhan
Code:
sed 's/search/replace/' file

i tried but not even one replacement did occur
let me tell my que once again
a file say 'x' with contents
hello
unix
hello
hello


after sed cmd execution i want the output as
HELLO
unix
hello
hello
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need downloading related help...but its not related to unix

Hi All, I am trying to dowmload the zip file "zkManageCustomers.zip " but i dont have access. Can anyone help me to download this file See the below link- http://www.ibm.com/developerworks/opensource/library/wa-aj-open/index.html?ca=drs- Please help me as early as... (1 Reply)
Discussion started by: aish11
1 Replies

2. Filesystems, Disks and Memory

FC related disks

Dear Friends, I would like know what are FC related disks and how it will be viewed by generic OSes (Unix, Unix like, Windows & etc.) AFAIK it is viewed by generic OS as SCSI. Can we have FC related disks as internal storage(physically) of general purpose machine (Server / PC /... (1 Reply)
Discussion started by: Tlogine
1 Replies

3. Shell Programming and Scripting

Question related to sed or awk or perl

Hi All, I have a big file of 100,000 lines with the following format: 1,736870,736870,1,2,5,547,1253889535,1253889775,240,30,152.163.141.8,US,0,00,-g 1253889445 1,881246,881246,1,2,6,402,1253889535,1253889775,240,30,152.163.141.8,US,0,00,-g 1253889445... (4 Replies)
Discussion started by: toms
4 Replies

4. Shell Programming and Scripting

count related..

is it possible to count the no of line in a zip file with out un compress the zip file.. (3 Replies)
Discussion started by: alexMar
3 Replies

5. Shell Programming and Scripting

Scripting related .

Could any body give the solution/script to get the below... 1.script will run and detcect the files having 0kb size , and give the solution in a out put file.(Will search the file in the path let say /abc/M/) 2.Same as the above also send a mail to your mails id , with the file name stating... (13 Replies)
Discussion started by: alexMar
13 Replies

6. UNIX for Advanced & Expert Users

assistance requested (sed related)

I gotta write a command to change the accounts in /etc/passwd that use a shell other than the bash to bash shell. those accounts that dont use a shell shouldnt get modified. assuming all the shell programs end in sh and other programs dont. and the result should go into /etc/passwd.rev any hint? (4 Replies)
Discussion started by: metalwarrior
4 Replies

7. Shell Programming and Scripting

sed related query

Hi I have a file which looks like this //string = "abcd"; //info //string = "*pqrs"; //add string = "#123"; //sub //string = "#1234567890" data = check(string) //string = "#1234567890" I want to modify this as string = "#987"; //mult data = check(string) How do i do that? (1 Reply)
Discussion started by: gopsman
1 Replies

8. UNIX for Dummies Questions & Answers

How are the following two commands related?

Trying to get through UNIX class that I mostly missed due to illness. If anyone can help me with this question I'd appreciate it. Thank you. How are the following two commands related? 1s -1R /proc ps ax (1 Reply)
Discussion started by: radhanuja
1 Replies

9. UNIX for Dummies Questions & Answers

oracle related

Plz. help me for returning set of values from oracle to unix array? (1 Reply)
Discussion started by: harsh_kats
1 Replies

10. UNIX for Advanced & Expert Users

x windows related

Hello, I am learning X/Motif programming.I wanted some information about how to create animations using this. can you please suggest me some website which contains this information?? I did not know where to post this thread.So I just posted it here. Thanks in advance. shilpa (1 Reply)
Discussion started by: informshilpa
1 Replies
Login or Register to Ask a Question