Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Extracting string using regular exp
Name: toshio Date: November 13, 2003 at 04:29:32 Pacific OS: Solaris Cshell CPU/Ram: 128
Comment:
Hi. I need help to extract a particular string in unix.Here's the text i have.
18713440 0 53 Nov 12 17:43 ./t3ix 2342344 3 446 Nov 14 15:23 ./t4
I need to extract date info, e.g Nov 12 As this is always 3 characters, space then 2 numeric, would using regular expression combined with sed be the answer ? Or are there other ways to extract that string. Thanks for your help
Name: toshio Date: November 13, 2003 at 04:31:41 Pacific
Reply:
Oops. The spaces in the text are not fixed. It's always different for diffent rows. Thanks
0
Response Number 2
Name: nails Date: November 13, 2003 at 08:15:25 Pacific
Reply:
Hi:
Are the fields always the 4th and 5th? If so, awk will work:
awk ' { print $4 $5 } ' data.file
Regards,
Nails
0
Response Number 3
Name: toshio Date: November 14, 2003 at 03:10:22 Pacific
Reply:
Thanks for your help Nails ! This was exactly what I was looking for. Had difficulty with the 'cut' cmd, but I guess this is good enough. Actually I'm trying to execute this piece of code so I can traverse through the output easily.
Summary: How to use sed to extract the text I have a text file look like this: /home1/users/usr1/bill.txt /home1/users/usr2/bom.txt /tmp/cost.txt All filename extension ended with txt. I need to output the a...
Summary: I am trying to extract a number from a string using 'sed'. This works fine on Linux/Unix but when i do the same on windows XP its creating problems. The code is as follows : <mkdir dir="${build.dir...
Summary: Hi, I am tring to replace a tring that contains 'href' with '\012' which is a newline in octal ASCII using tr, the command is below: cat newsletter.txt | tr 'href' '\012' > newfilename But the res...