![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| doubt regardin regex in grep | evergreen_cool | Shell Programming and Scripting | 4 | 09-02-2008 06:57 PM |
| grep with Regex help! | mvalonso | UNIX for Dummies Questions & Answers | 3 | 06-01-2007 12:36 PM |
| Problem with grep Regex Error | lweegp | Shell Programming and Scripting | 6 | 11-16-2006 12:04 AM |
| grep regex problem | iceman | Shell Programming and Scripting | 2 | 02-06-2005 08:44 AM |
| use of regex on grep | solea | UNIX for Dummies Questions & Answers | 0 | 09-30-2004 08:13 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Help with grep and regex
Hi all,
I'm a beginner with linux, regex, grep, etc I am trying to get data out of a file that has about 13,000 lines in this format name - location I want to grep all the names out to one file and the locations to another so I can put them into a spreadsheet. Some have hyphenated names or hyphenated locations as well to complicate things. The way I was going to approach it was to first grep out the lines with only one hypen to one file and all the ones with multiple hyphens to another. Then I need an expression to select all data on one side of the hyphen and place it into one file, and the data on the other side of the hyphen into another file. I'm going through all the tutorials I can find, but they don't read much better than man pages and I can't figure out how to do what I want. Can anyone help me get started with this? Thanks in advance! |
| Forum Sponsor | ||
|
|
|
|||
|
Code:
sed -e 's/ - / /' Next up, read the manual for the "cut" command. |
|
|||
|
well that removed all the hyphens between name and location WITHOUT removing the words that needed to be hyphenated, so that's a start, but it still doesn't allow me to separate the data on either side of the delimiting hyphen... Unless I did something wrong.. I typed:
sed -e 's/ - / /' list > list2 Thanks! Oh wait, I see where you were going... The problem now is that there are spaces in names and locations, and this appears to have placed a space between the data. Not enough to separate the data logically, at least for Calc. |
|
|||
|
A tab is a more conventional separator character, although of course it looks like just whitespace.
To type a tab at the command line, you often need to use some escape code, like ctrl-v tab to get a literal tab. |
|
|||
|
sigh... still working on this.
There are 2 more things I have to figure out. . How do you indicate all lines beginning with specific file paths for example: A/A/* sed -e 's/"A/A/*"/ /g' > newfile doesn't seem like it's going to work... And how do I indicate a blank line? |
|||
| Google The UNIX and Linux Forums |
| Tags |
| linux, regex, regular expressions |
| Thread Tools | |
| Display Modes | |
|
|