Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reg exp?

Status
Not open for further replies.

mikeboz

MIS
May 18, 2000
41
US
I cant seem to get my regular expression to work in the last sed statement in the following script. Any help would be great. THANKS

below the following script is sample input data, also are the results I would like to see after the script is run.

ls /users/REL_DWGS/17xxx > /users/cocreate/tools/sed_files/file_names
awk '{ print $1 " "$1" "$1 }' /users/cocreate/tools/sed_files/file_names > /users/cocreate/tools/sed_files/file_names2
sed s/.mi//2 /users/cocreate/tools/sed_files/file_names2 >
/users/cocreate/tools/sed_files/file_names3
sed s/.mi//2 /users/cocreate/tools/sed_files/file_names3 >
/users/cocreate/tools/sed_files/file_names4
sed /^hp_/d /users/cocreate/tools/sed_files/file_names4 >
/users/cocreate/tools/sed_files/file_names5
sed s/r..//2 /users/cocreate/tools/sed_files/file_names5 >
/users/cocreate/tools/sed_files/file_names6
sed s/\ /L/2 /users/cocreate/tools/sed_files/file_names6 >
/users/cocreate/tools/sed_files/file_names7
sed s/L[a-zA-Z0-9]*r/r/g /users/cocreate/tools/sed_files/file_names7 >

input file

17047r01 17047 17047r01
17056r01 17056 17056r01
17056r02.mi 17056 17056r02
17057r01 17057 17057r01
17057r02 17057 17057r02
17057r03 17057 17057r03
17119r01 17119 17119r01
17128r01 17128 17128r01
17132-000r01 17132-000 17132-000r01
17132-068r02 17132-068 17132-068r02
17132-071r01 17132-071 17132-071r01
17132-071r02 17132-071 17132-071r02
17132-073r01 17132-073 17132-073r01
17132-074r01 17132-074 17132-074r01
17158r01 17158 17158r01
17158r02 17158 17158r02
17370r06.mi 17370 17370r06
17372r01 17372 17372r01
17771r01ob.mi 17771ob 17771r01ob
17779r01 17779 17779r01
17780r01 17780 17780r01
17781r01 17781 17781r01
17781r02.mi 17781 17781r02
17782r01 17782 17782r01
17782r02.mi 17782 17782r02


output file

17047r01 17047 r01
17056r01 17056 r01
17056r02.mi 17056 r02
17057r01 17057 r01
17057r02 17057 r02
17057r03 17057 r03
17119r01 17119 r01
17128r01 17128 r01
17132-000r01 17132-000 r01
17132-068r02 17132-068 r02
17132-071r01 17132-071 r01
17132-071r02 17132-071 r02
17132-073r01 17132-073 r01
17132-074r01 17132-074 r01
17158r01 17158 r01
17158r02 17158 r02
17370r06.mi 17370 r06
17372r01 17372 r01
17771r01ob.mi 177771ob r01ob
17779r01 17779 r01
17780r01 17780 r01
17781r01 17781 1r01
17781r02.mi 17781 r02
17782r01 17782 r01
17782r02.mi 17782 r02
 
OPPPPPS MISTAKE ABOVE
my sample data should have an 'L' in place of the second occurance of a space.
 

I think this will do what you want.

sed 's/L[^r]*/ /' r.txt

I think your solution needs a - after the [

Hope this helps.

CaKiwi
 
That did it. but I dont understand the syntax.

Thanks a bunch!
 


A ^ as the first character in square brackets means exclude the the following character(s) from the search. So [^r]* means find any number of characters which are not r

CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top