![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to print the word | ss_psm | UNIX for Dummies Questions & Answers | 0 | 03-17-2008 10:22 AM |
| Using first word and print their contents using awk | cdfd123 | Shell Programming and Scripting | 6 | 10-10-2007 12:12 AM |
| print selected lines | tonet | Shell Programming and Scripting | 6 | 10-08-2007 02:50 AM |
| print selected rows with awk | tonet | Shell Programming and Scripting | 6 | 09-27-2007 03:23 AM |
| Print out just a word from the file | Kinki | Shell Programming and Scripting | 8 | 02-20-2005 07:40 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Print out a selected word.
Hi can anyone assist me on my problem.
I try to grep 1 word in 1 line data. Example like below. * Data below located in a.txt, i just wanna grep just processing-time = "12" total-octets = "20080718214210Z" total-pages = "" octets-completed = "20080721064351Z" pages-completed = "2" processing-time = "12" I searched the threat and found 1 solution like below, unfortunately it is just work if the word located in different row not in 1 line row. sed -ne '/^[ ]*processing-time/s#^\([^=][^=]*\)=\([^/][^/]*\).*#\12#p' Please assits |
| Forum Sponsor | ||
|
|
|
|||
|
Thanks it is work for me.
1 more, how about if i need to grep 2 words octets-completed = "20080721064351Z" and processing-time = "12" it is located in same 1 file in 1 line data, as below. Quote:
|
|
|||
|
Quote:
Code:
echo 'total-octets = "20080718214210Z" total-pages = "" octets-completed = "20080721064351Z" pages-completed = "2" processing-time = "12"'|sed -e 's/ = /=/g;s/ /\n/g' Code:
total-octets="20080718214210Z" total-pages="" octets-completed="20080721064351Z" pages-completed="2" processing-time="12" /Lakris |
|
|||
|
Hi Lakris,
I tried to used your method using the pipe after the echo but it wouldn't work. Sorry if it is my mistake i am new in this shell field. Below is what i did My Code : Quote:
Quote:
|
|||
| Google The UNIX and Linux Forums |