Sponsored Content
Full Discussion: sed question
Top Forums UNIX for Dummies Questions & Answers sed question Post 302162012 by orahi001 on Sunday 27th of January 2008 07:38:38 PM
Old 01-27-2008
sed question

Hello,

I have a file where I need to search for a word in a line and then break the line into two lines.

I have the following file and I want the below result

File1:
PROJ=Workflow System CPPDOC=QUOTE
PROJ=center Workflow System CPPDOC=CONTRACT
PROJ=Workflow System CPPDOC=CPP CENTER
PROJ=center Workflow System CPPDOC=CPP TEAM
PROJ=CP flow System CPPDOC=TEST PLAN

Result:
PROJ=Workflow System
CPPDOC=QUOTE
PROJ=center Workflow System
CPPDOC=CONTRACT
PROJ=Workflow System
CPPDOC=CPP CENTER
PROJ=center Workflow System
CPPDOC=CPP TEAM
PROJ=CP flow System
CPPDOC=TEST PLAN

I started by trying to print the first part of the line up to CPPDOC for each line.

sed -n '/PROJ/,/CPPDOC/p' File1

but its just dumping the contents of File1

can someone explain why sed is not picking up the text with between the regular expresions?

Also, can someone shed light on another way to get the resulting file?


thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed Question

Hi, Is there any way to traverse the file once and look for the following conditions in one sweep instead of going over the file 3 times with different search criteria...... sed -n '/^ORA-07445/ p' /tmp/t$$ > ${OERRFILE} sed -n '/^ORA-00600/ p' /tmp/t$$ >> ${OERRFILE} ... (1 Reply)
Discussion started by: YS2002
1 Replies

2. Shell Programming and Scripting

sed question (again)

hello there, I have a sed question. I have a file (temp.srv), in it it has v1_host1 v2_host2 And I have another file (temp2.srv), in it is has v1_host3_date v1_host1 v2_host2 v2_host4_date v3_host5_date I had used a script to remove the name from temp2.srv base on the name inside... (3 Replies)
Discussion started by: ahtat99
3 Replies

3. Shell Programming and Scripting

sed question

Hi, When deleting lines using sed, as i understand the lines are redirected to the standard output. What i'm unclear about is how to actually modify the file? If I write the command sed '1,2d' test it will display lines one and 2 onto the screen however the file is not modified? I think my... (5 Replies)
Discussion started by: c19h28O2
5 Replies

4. Shell Programming and Scripting

sed question

Hi, :) can any body explain the following statement sed 's/\(\)- ]//g' cheers RRK (3 Replies)
Discussion started by: ravi raj kumar
3 Replies

5. Shell Programming and Scripting

sed question

I have a file that conatins following info Policy1=U|guestRoom=test1idCode=5(1):!:Amenity2=U|RoomId=testrma=4(1):!:| GuestRoomAmenity1=U|guestRoomId=testguest1id^rmaCode=5(1):!:| I need it to look like this Policy1=U|guestRoom=test1idCode Amenity2=U|RoomId=testrmaCode... (2 Replies)
Discussion started by: arushunter
2 Replies

6. UNIX for Dummies Questions & Answers

sed question

How would I use sed to print everything on the line after the regular expresion? I have a configuration file setting several variables. cfg.dat DDB = cpptest SUDBNAME = sucpptestdb host = cpptest Example I want to search for the regular expresion 'SUDBNAME =' and print everything on... (3 Replies)
Discussion started by: orahi001
3 Replies

7. Shell Programming and Scripting

Sed Question 1. (Don't quite know how to use sed! Thanks)

Write a sed script to extract the year, rank, and stock for the most recent 10 years available in the file top10_mktval.csv, and output in the following format: ------------------------------ YEAR |RANK| STOCK ------------------------------ 2007 | 1 | Exxon... (1 Reply)
Discussion started by: beibeiatNY
1 Replies

8. Shell Programming and Scripting

sed question

hi i have a file with this line: variable=/export/home/oracle I want to change the file so that the path is replaced with the value of another variable var2=/tmp/anything. how to do this in sed? thx (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

9. Shell Programming and Scripting

Sed question

I need to replace the numbers with a new string. How can I give a wildcard for the different # of numbers sed '/abcdef/s/abcdef=*/abcdef=999999/'<foo>foo1 From: To: abcdef=1234 abcdef=999999 abcdef=12345 abcdef=999999 abcdef=123456... (10 Replies)
Discussion started by: beppler
10 Replies

10. UNIX for Dummies Questions & Answers

SED question

I am trying to write a script that will take an input text file in the format person: place: phonenumber; person: place: phonenumber; person: place: phonenumber; ... and output it using sed too: Name ######## Location ######### Phone Number... (1 Reply)
Discussion started by: jmack56
1 Replies
PROJ(1)                                                       General Commands Manual                                                      PROJ(1)

NAME
cs2cs - cartographic coordinate system filter SYNOPSIS
cs2cs [ -eEfIlrstvwW [ args ] ] [ +opts[=arg] ] [ +to [+opts[=arg]] ] file[s] DESCRIPTION
Cs2cs performs transformation between the source and destination cartographic coordinate system on a set of input points. The coordinate system transformation can include translation between projected and geographic coordinates as well as the application of datum shifts. The following control parameters can appear in any order: -I method to specify inverse translation, convert from +to coordinate system to the primary coordinate system defined. -ta A specifies a character employed as the first character to denote a control line to be passed through without processing. This option applicable to ascii input only. (# is the default value). -e string String is an arbitrary string to be output if an error is detected during data transformations. The default value is: * *. Note that if the -b, -i or -o options are employed, an error is returned as HUGE_VAL value for both return values. -E causes the input coordinates to be copied to the output line prior to printing the converted values. -l[p|P|=|e|u|d]id List projection identifiers with -l, -lp or -lP (expanded) that can be selected with +proj. -l=id gives expanded description of projection id. List ellipsoid identifiers with -le, that can be selected with +ellps, -lu list of cartesian to meter conversion factors that can be selected with +units or -ld list of datums that can be selected with +datum. -r This options reverses the order of the expected input from longitude-latitude or x-y to latitude-longitude or y-x. -s This options reverses the order of the output from x-y or longitude-latitude to y-x or latitude-longitude. -f format Format is a printf format string to control the form of the output values. For inverse projections, the output will be in degrees when this option is employed. If a format is specified for inverse projection the output data will be in decimal degrees. The default format is "%.2f" for forward projection and DMS for inverse. -[w|W]n N is the number of significant fractional digits to employ for seconds output (when the option is not specified, -w3 is assumed). When -W is employed the fields will be constant width and with leading zeroes. -v causes a listing of cartographic control parameters tested for and used by the program to be printed prior to input data. The +args run-line arguments are associated with cartographic parameters and usage varies with projection and for a complete description see Cartographic Projection Procedures for the UNIX Environment--A User's Manual ) and supplementary documentation for Release 4. The cs2cs program requires two coordinate system definitions. The first (or primary is defined based on all projection parameters not appearing after the +to argument. All projection parameters appearing after the +to argument are considered the definition of the second coordinate system. If there is no second coordinate system defined, a geographic coordinate system based on the datum and ellipsoid of the source coordinate system is assumed. Note that the source and destination coordinate system can both be projections, both be geographic, or one of each and may have the same or different datums. Additional projection control parameters may be contained in two auxiliary control files: the first is optionally referenced with the +init=file:id and the second is always processed after the name of the projection has been established from either the run-line or the con- tents of +init file. The environment parameter PROJ_LIB establishes the default directory for a file reference without an absolute path. This is also used for supporting files like datum shift files. One or more files (processed in left to right order) specify the source of data to be transformed. A - will specify the location of pro- cessing standard input. If no files are specified, the input is assumed to be from stdin. For input data the two data values must be in the first two white space separated fields and when both input and output are ASCII all trailing portions of the input line are appended to the output line. Input geographic data (longitude and latitude) must be in DMS format and input cartesian data must be in units consistent with the ellip- soid major axis or sphere radius units. Output geographic coordinates will be in DMS (if the -w switch is not employed) and precise to 0.001" with trailing, zero-valued minute-second fields deleted. EXAMPLE
The following script cs2cs +proj=latlong +datum=NAD83 +to +proj=utm +zone=10 +datum=NAD27 -r <<EOF 45d15'33.1" 111.5W 45d15.551666667N -111d30 +45.25919444444 111d30'000w EOF will transform the input NAD83 geographic coordinates into NAD27 coordinates in the UTM projection with zone 10 selected. The geographic values of this example are equivalent and meant as examples of various forms of DMS input. The x-y output data will appear as three lines of: 1402285.99 5076292.42 0.000 SEE ALSO
proj(1U), Cartographic Projection Procedures for the UNIX Environment--A User's Manual, (Evenden, 1990, Open-file report 90-284). Map Projections Used by the U. S. Geological Survey (Snyder, 1984, USGS Bulletin 1532). Map Projections--A Working Manual (Snyder, 1988, USGS Prof. Paper 1395). An Album of Map Projections (Snyder & Voxland, 1989, USGS Prof. Paper 1453). HOME PAGE
http://www.remotesensing.org/proj 2000/03/21 Rel. 4.4 PROJ(1)
All times are GMT -4. The time now is 07:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy