Subject: Re: Substituting text with sed
Subject: Re: Substituting text with sed
Subject: Re: Removing ">" from files.
Subject: Re: Removing ">" from files.
Subject: Re: Removing ">" from files.
(SED: delete blanks, combine fields)
Subject: Re: SED question
Subject: Re: SED question
Subject: Re: SED question
Subject: Re: SED question
Subject: Re: search and replace in unix
Subject: Re: Newbie: extracting lines from a file
Newsgroups: comp.unix.questions
From: bmarcum@iglou.iglou.com (Bill Marcum)
Subject: Re: Substituting text with sed
Date: Tue, 13 Feb 1996 02:43:49 GMT
Lines: 27
In article <4flose$629@nic.ftns.no>, John Sletten <johns@ftns.no> wrote:
>sed s/"oldname "/"newname "/g userdb
>
>How do I match the tab character ?
Use the tab key. To match either space or tab, you could use [ ]
(space and tab inside the [ ])
>I would also prefer that sed did not replace a space with a tab or vice
>versa.
sed s/"oldname\([ ]\)"/"newname\1"/g userdb
>
>BTW, if anyone could think of a better way of doing string substitution I
>would be grateful.
>
>Thanks in advance
>
>John Sletten
>Oslo, Norway
>
>
--
Bill Marcum bmarcum@iglou.com
February 8, 1996: A day that will live in infamy.
The CDA is pure bullHelms. Congress should get their heads out of their
McConnells and repeal it now.
--
From: ray@camco1.celestial.com (Ray A. Jones)
Newsgroups: comp.unix.questions
Subject: Re: Substituting text with sed
Date: 17 Feb 1996 19:38:53 GMT
Lines: 34
John Poltorak (jpolt@bradnet.demon.co.uk) wrote:
: John Savage <koala@sydney.dialix.com.au> writes:
: > >How do I match the tab character ?
: > >
: > >I would also prefer that sed did not replace a space with a tab or vice
: > >versa.
: >
: > sed 's/oldname\([ ]\)/newname\1/g' userdb
: >
: > Between the [ and ] you type the two characters <space><tab>
: Is there any special way to write the tab character?
: The tab key itself doesn't seem to work, and neither does \t.
: Is there any way to enter the hexadecimal representation of characters?
If you are using vi to write the above script you can a least see the tab
characters by [ESCAPE] (to get to the command mode) and then:
:set list
This will show the tabs as ^I and will show [RETURN] as $
:set nolist
to turn off the feature.
Ray A. Jones
--
INTERNET: ray@Celestial.COM Ray A. Jones; Celestial Systems, Inc.
URL: http://www.celestial.com One Mercer Plaza, Suite S100
Mercer Island, WA 98040; (206) 236-1676
Manufacturer of InterRack (Internet-in-a-Rack), a full turn-key
system, including all the hardware, software, installation, setup, training
and support for businesses and Internet Service Providers
--
From: cain@pinn.net (James Cain)
Newsgroups: comp.unix.questions
Subject: Re: Removing ">" from files.
Date: 28 Feb 1996 20:51:22 GMT
Lines: 31
Jason R. Heminger (ching@wpi.edu) wrote:
: I was wondering if there was an easy way to remove the >'s from the beginning
: of lines from forwarded mail through emacs or sed or whathave you. I checked
: the FAQ to no avail.
: Thanks!
Sure, one method in vi (sorry) command (or movement, whatever) mode, enter
:1,$s/^>// ...where, reading from the bottom
^^ ^^ ^^ ^
|| || | |
|| || | |___with nothing (empty //)
|| || |___which is beginning of line (^) and >
|| ||___substitue (stuff enclosed in //)
|| |___to last line of file
||__from first line of file
|__(esc, first, then) : puts you at command line
You may want to substitue "/^> /" (notice space after >) for the string to
be substituted. If I recall there is a space after the > in reply mail.
Otherwise the result will be indented one space.
Hope it helps...jc
--
/\/\--------------------------------------------------------- o
> James Cain / Good - Cheap - Fast | 8 __
> eMail: cain@pinn.net / Pick any two! | _i_|[]|
> aka: cain@prc.prc.mrms.navy.mil /#include <std.disclaimer>|\__|______|
\/\/---------------------------------------------------------/-(o_o_o_o)
--
From: mcclellantj@harrier (Tad McClellan)
Newsgroups: comp.unix.questions
Subject: Re: Removing ">" from files.
Date: 28 Feb 1996 21:03:37 GMT
Lines: 22
Reply-To: mcclellantj@lfwc.lockheed.com
Jason R. Heminger (ching@wpi.edu) wrote:
: I was wondering if there was an easy way to remove the >'s from the beginning
: of lines from forwarded mail through emacs or sed or whathave you. I checked
: the FAQ to no avail.
in vi:
:%s/^>//
with sed:
sed -e 's/^>//' <withem >withoutem
with perl:
perl -p -i -e 's/^>//;' filename
with tr:
tr -d '>' '' <withem >withoutem
--
Tad McClellan, Logistics Specialist (IETMs and SGML guy)
email: mcclellantj@lfwc.lockheed.com
All I want, is a little more than I'll ever get.
--
From dufresne@darkstar.sysinfo.comTue Mar 5 02:29:45 1996
Date: Thu, 29 Feb 1996 02:22:00 -0600 (CST)
From: "R. DuFresne" <dufresne@darkstar.sysinfo.com>
To: mcclellantj@lfwc.lockheed.com
> From: mcclellantj@harrier (Tad McClellan)
> Newsgroups: comp.unix.questions
> Subject: Re: Removing ">" from files.
> Date: 28 Feb 1996 21:03:37 GMT
> Lines: 22
> Reply-To: mcclellantj@lfwc.lockheed.com
>
> Jason R. Heminger (ching@wpi.edu) wrote:
> : I was wondering if there was an easy way to remove the >'s from the beginning
> : of lines from forwarded mail through emacs or sed or whathave you. I checked
> : the FAQ to no avail.
>
>
> in vi:
> :%s/^>//
>
> with sed:
> sed -e 's/^>//' <withem >withoutem
>
> with perl:
> perl -p -i -e 's/^>//;' filename
>
> with tr:
> tr -d '>' '' <withem >withoutem
filename: test
> access to the ether, And then use the Networking Monitoring tool to track
> packets. It's a very nice interface - dumps all the info to an available
> SQL Server, including packet contents. It tracks statistics based on MAC
> addresses if I remember right though, but it does include a vendor database
darkstar:~$ tr -d '>' '' < test > test.tr3
tr: only one string may be given when deleting without squeezing repeats
darkstar:~$
darkstar:~$ more test.tr3
darkstar:~$
darkstar:~$ tr -d ">' '" < test > test.tr
darkstar:~$
darkstar:~$ more test.tr
accesstotheether,AndthenusetheNetworkingMonitoringtooltotrack
packets.Itsaveryniceinterface-dumpsalltheinfotoanavailable
SQLServer,includingpacketcontents.IttracksstatisticsbasedonMAC
addressesifIrememberrightthough,butitdoesincludeavendordatabase
darkstar:~$ tr -d -s '>' '' < test > test.tr2
darkstar:~$
darkstar:~$ more test.tr2
access to the ether, And then use the Networking Monitoring tool to track
packets. It's a very nice interface - dumps all the info to an available
SQL Server, including packet contents. It tracks statistics based on MAC
addresses if I remember right though, but it does include a vendor database
>
> --
> Tad McClellan, Logistics Specialist (IETMs and SGML guy)
> email: mcclellantj@lfwc.lockheed.com
> All I want, is a little more than I'll ever get.
Ron DuFresne
From: demas@sunspot.tiac.net (Charles Demas)
Newsgroups: comp.unix.admin,comp.unix.questions
Subject: Re: SED question
Date: 9 Mar 1999 21:02:43 GMT
Lines: 45
To: Dean <dcousins@sbsc.siemens.co.uk>
In article <7c3u77$ld8$1@roch.zetnet.co.uk>,
Dean <dcousins@sbsc.siemens.co.uk> wrote:
>Hi
>
>I have a file with data in as below, I need to take the space's out of the
>lines with double numbers in. eg SV10, SV11, SV12
>SV1 5Z218
>SV2 5Z074
>SV3 5Z123
>SV10 03573
>SV11 07215
>SV12 09847
>SV13 03529
>
>eg.
>
>SV1 5Z218
>SV2 5Z074
>SV3 5Z123
>SV1003573
>SV1107215
>SV1209847
>SV1303529
>
>I have tried sed s/CV.. /&/g it does nothing can some one help please.
Here are two methods with sed:
sed -e '/^SV[0-9][0-9]/s/ //' infile
sed -e 's/\(SV[0-9][0-9]\) /\1/' infile
actually, on the actual sample shown, this would work too:
sed -e 's/\([0-9][0-9]\) /\1/' infile
Chuck Demas
Needham, Mass.
--
Eat Healthy | _ _ | Nothing would be done at all,
Stay Fit | @ @ | If a man waited to do it so well,
Die Anyway | v | That no one could find fault with it.
demas@tiac.net | \___/ | http://www.tiac.net/users/demas
--
Newsgroups: comp.unix.admin,comp.unix.questions
From: "Kurt J. Lanza" <kjl@inforonics.com>
Subject: Re: SED question
Reply-To: kjl@inforonics.com
Mime-Version: 1.0
Date: Tue, 9 Mar 1999 21:12:47 GMT
Lines: 35
Dean wrote:
>
> Hi
>
> I have a file with data in as below, I need to take the space's out of the
> lines with double numbers in. eg SV10, SV11, SV12
> SV1 5Z218
> SV2 5Z074
> SV3 5Z123
> SV10 03573
> SV11 07215
> SV12 09847
> SV13 03529
>
> eg.
>
> SV1 5Z218
> SV2 5Z074
> SV3 5Z123
> SV1003573
> SV1107215
> SV1209847
> SV1303529
>
> I have tried sed s/CV.. /&/g it does nothing can some one help please.
>
Translating your sed command: Change any 4-letter string consisting
of the the letters "CV" followed by any two characters (including
spaces) to itself. Not surprising that it does nothing. Nothing is
exactly what you told it to do. Try something like:
s/\(SV[0-9][0-9]\) /\1/
Translation is left as an exercise for the student.
--
From: foo@bar.nospam.com (dave)
Newsgroups: comp.unix.admin,comp.unix.questions
Subject: Re: SED question
Date: Wed, 10 Mar 1999 05:34:15 GMT
Lines: 39
sed 's/\(...[^ ]\) \(.*\)/\1\2/'
On Tue, 9 Mar 1999 19:51:45 -0000, "Dean"
<dcousins@sbsc.siemens.co.uk> wrote:
>Hi
>
>I have a file with data in as below, I need to take the space's out of the
>lines with double numbers in. eg SV10, SV11, SV12
>SV1 5Z218
>SV2 5Z074
>SV3 5Z123
>SV10 03573
>SV11 07215
>SV12 09847
>SV13 03529
>
>eg.
>
>SV1 5Z218
>SV2 5Z074
>SV3 5Z123
>SV1003573
>SV1107215
>SV1209847
>SV1303529
>
>I have tried sed s/CV.. /&/g it does nothing can some one help please.
>
>Thanks
>Dean Cousins
>
>
>
+-----------------------------+----------------+
| please@do.not send@me.spam |@mindpsring.com |
| iwill@not.buy.from.spammers |davegrantier |
+-----------------------------+----------------+
--
From: Atul Pinge <atulmanisha@earthlink.net>
Newsgroups: comp.unix.admin,comp.unix.questions
Subject: Re: SED question
Date: Wed, 10 Mar 1999 23:38:47 -0700
Lines: 45
Mime-Version: 1.0
Reply-To: atulmanisha@earthlink.net
Hello,
Try
sed 's/^\(SV[0-9][0-9]\) /\1/'
Here meaning of various regular expressions are as following:
^ : Beginning of line
\(..\): Braced regular expression, remembers whatever was matched between
the braces and can be referred as \1 \2 in search as well as replacement
pattern
[0-9]: Match any character between 0 to 9
Atul
Dean wrote:
> Hi
>
> I have a file with data in as below, I need to take the space's out of the
> lines with double numbers in. eg SV10, SV11, SV12
> SV1 5Z218
> SV2 5Z074
> SV3 5Z123
> SV10 03573
> SV11 07215
> SV12 09847
> SV13 03529
>
> eg.
>
> SV1 5Z218
> SV2 5Z074
> SV3 5Z123
> SV1003573
> SV1107215
> SV1209847
> SV1303529
>
> I have tried sed s/CV.. /&/g it does nothing can some one help please.
>
> Thanks
> Dean Cousins
--
From: jbaugher@rnet.com
Newsgroups: alt.unix.wizards
Subject: Re: search and replace in unix
Date: Mon, 29 Mar 1999 15:21:33 GMT
Lines: 31
Maybe something like:
for ${filename} in *
do
sed 's/old address/new address/g' ${filename} >/tmp/hold$$
mv /tmp/hold$$ ./${filename}
done
In article <36FF13C7.82E6E720@mcs.com>,
Paul Clifford <pcliff@mcs.com> wrote:
> I have about 150 ascii text files located in one directory on a unix
> system. I want to search for all occurrences of a string of text (an old
> e-mail address) in every file and replace it with a new string (a new
> e-mail address).
>
> Is there a command I could run from a the unix shell, or from within VI,
> to change this text in all files in which it appears?
>
> Thanks.
>
>
Jason Baugher
Extreme Systems Consulting
Systems Administration, Custom Programming
jbaugher@rnet.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Newsgroups: comp.unix.questions
From: af137@torfree.net (Al Aab)
Subject: Re: Newbie: extracting lines from a file
Date: Mon, 15 Mar 1999 08:15:09 GMT
Lines: 20
sed "1,20" infile > first.20.lines
sed '21,40' infile > second.20.lines
sed '21,$' infile > infile-20
sed '41,$' infile > infile-40
if the infile is long
& u r in hurry
add the q (quit comand)
-------------------------------------------------
to master regular expressions
to master sed
join my informal email list seders
af137@torfree.net
-------------------------------------------------
--
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator sed u soon
it is not zat we do not see the s o l u t i o n
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
--
|
Hosted by: |
|
©copyright 1995-2002 sysinfo.com