Help with sed editor


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with sed editor
# 1  
Old 03-27-2011
Help with sed editor

I am a newbie to Unix and Linux,
Code:
sed "32,45s/[()]//g" file  : 
sed "s/\([0-9]\)-\([0-9]\)/\1\2/g" file

How do we describe these commands in English ? Please help.

Last edited by Scott; 03-27-2011 at 11:51 AM.. Reason: Please use code tags
# 2  
Old 03-27-2011
Code:
sed "32,45s/[()]//g" file

This line will delete all parenthesis that are in "file"
from line 32 to line 45 (included), and this will be done globally
(so all occurrence in the line will be deleted even if there are more
than 1 parenthesis per line (where 32 <= linenumber <= 45)

Code:
sed "s/\([0-9]\)-\([0-9]\)/\1\2/g" file

this line will suppress all minus sign that are in between 2 figures

Code:
$ cat myt
I[()]A
321-432 654-9879 6754-6564 -
$ sed "s/[()]//g" myt
I[]A
321-432 654-9879 6754-6564 -
$ sed "s/\([0-9]\)-\([0-9]\)/\1\2/g" myt
I[()]A
321432 6549879 67546564 -
$


Last edited by ctsgnb; 03-29-2011 at 04:45 AM..
This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 03-29-2011
Thanks a lot for your help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Open Source

What editor does everyone use?

I was looking through the topics and I wasn't sure if this was the best place to post this question: I was wondering, out of curiosity, which software everyone was using to code their scripts in. I do mostly sh/ksh and my favorite has always been EditPlus because it is small, fast, yet powerful.... (409 Replies)
Discussion started by: yongho
409 Replies

2. Shell Programming and Scripting

Insert charactera in 1st position of specific lines using vi editor or sed command

Dear all, i am having text file like below surya rama ranga laxman rajesh reddy i want add string (OK) before a text from line 3 to 5 the result will be surya rama OK ranga OK laxman OK rajesh reddy (1 Reply)
Discussion started by: suryanarayana
1 Replies

3. UNIX for Advanced & Expert Users

more than 1 vi editor

Hi, What's the process to open 2 vi editor at a same time. Plz let me know. Thanx (5 Replies)
Discussion started by: reply2soumya
5 Replies

4. Solaris

Epic Editor was not able to obtain a license for your use. Feature Epic Editor :Licen

Epic Editor was not able to obtain a license for your use. Feature Epic Editor :License server is down (1 Reply)
Discussion started by: durgaprasadr13
1 Replies

5. Shell Programming and Scripting

set EDITOR=vi -> default editor not setting for cron tab

Hi All, I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e even after setting editor to vi by set EDITOR=vi it does not open a vi editor , rather it do as below..... ///////////////////////////////////////////////////// $ set... (6 Replies)
Discussion started by: aarora_98
6 Replies

6. UNIX for Dummies Questions & Answers

Pasting text in VI editor from a different editor

Hi, I knw its a silly question, but am a newbie to 'vi' editor. I'm forced to use this, hence kindly help me with this question. How can i paste a chunk 'copied from' a different editor(gedit) in 'vi editor'? As i see, p & P options does work only within 'vi'. (10 Replies)
Discussion started by: harishmitty
10 Replies

7. UNIX and Linux Applications

VI Editor

I need to delete a line of statement with vi editior in linux, i am using rm but won't work. (3 Replies)
Discussion started by: doyindayo
3 Replies

8. Shell Programming and Scripting

how to dereference the variable in sed editor

Hi I am trying to do the substitution using the 'sed' editor. In the line below I am trying to substitute all instances of XXX by the value of the variable PX sed 's/XXX/${PX}/g' ${TEMPLETE} > ${TEMPLETE}.${PX} The problem is that 'sed' editor takes ${PX} literary (without retrieving the... (2 Replies)
Discussion started by: aoussenko
2 Replies

9. UNIX and Linux Applications

vi editor, grep or sed

I'm currently building a system to perfom a check on some operations on a unix system, i'm very new to unix and i need help. i know 'uname' displays the name of the OS been used, but how do u send the content of uname into a directory or file ? (1 Reply)
Discussion started by: dasadino
1 Replies

10. Shell Programming and Scripting

Vi editor ?

Hello everybody, My question is: how to add /tmp/work at the end of line in vi editor. my file looks like: cp file1 cp file2 cp file3 **** I need to add " /tmp/work" at the end of each line. I tried this :%s/$/" /tmp/work" and this :%s/$/\ /tmp/work\/ but it does not work. (2 Replies)
Discussion started by: billy5
2 Replies
Login or Register to Ask a Question