help with sed or awk with less pipe


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with sed or awk with less pipe
# 1  
Old 05-03-2012
help with sed or awk with less pipe

Code:
<tr><th align=right valign=top>Faulty_Part</th><td align=left valign=top>readhat version 6.0</td></tr> <tr><th align=right valign=top>Submit_Date</th><td align=left valign=top>2011-04-28 02:08:02</td></tr> .......(a long string)

I want to get all the field between "left valign=top>" and " </td></tr>" with awk or sed with less pipe

something like :

readhat version 6.0 2011-04-28 02:08:02 ......

any help?
# 2  
Old 05-04-2012
Code:
$ nawk -F"[<>]" '{for(i=1;i<=NF;i++)if($i~/left valign=top/){print $(i+1);next}}' input.txt
readhat version 6.0

# 3  
Old 05-04-2012
Code:
$ awk -F\> '/^td.*top>/{print $NF}' RS="<" ORS=" " inputfile
readhat version 6.0 2011-04-28 02:08:02

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a value in a pipe delimited line (unsig sed,awk)

Hi, I want to insert a value (x) in the 3rd position of each line in a file like below a|b|c|d|1 a|b|c|d a|b|c|d|e|1 a|b|cso that output file looks like a|b|x|c|d|1 a|b|x|c|d a|b|x|c|d|e|1 a|b|x|cI can do that using perl as below #!/usr/bin/perl -w use strict; #inserting x at... (5 Replies)
Discussion started by: sam05121988
5 Replies

2. Shell Programming and Scripting

Use less pipe for grep or awk sed to print the line not include xx yy zz

cat file |grep -v "xx" | grep -v "yy" |grep -v "zz" (3 Replies)
Discussion started by: yanglei_fage
3 Replies

3. Shell Programming and Scripting

Sed, replace comma with pipe. but ignore qoutes

hi, I am trying to replace comma with pipe, but the issue is that i want to ignore the commas inside qoutes. for example: i have file with the string: 1,"2,3",4,"5","6,7" the result should be : 1|"2,3"|4|"5"|"6,7" i trying to use sed and awk (match function) for that, but i did not... (4 Replies)
Discussion started by: gabik
4 Replies

4. Shell Programming and Scripting

Pipe awk's output to sed for deletion

Hi Friends, I am using a command that prints certain lines from a file. For ex: cat input abc chr1 456 def chr1 789 ghi chr1 999 jjj chr1 777 jhk chr7 914 My command awk '{if($2=="chr1" && $3>=456 && $3<=999) {print $0}}' OFS="\t" input Output being printed is abc chr1 456 (7 Replies)
Discussion started by: jacobs.smith
7 Replies

5. UNIX Desktop Questions & Answers

How to squeeze multiple pipe character '|' into single '|' using sed?

Hi, I am trying to convert multiple Unix pipe symbol or bar into single |. I have tried with the following sed statements, but, no success :(. I need it using sed only echo "sed 's/\|\+/\|/g' sed 's/*/\|/' sed 's/\|*/|/' sed -r 's/\|+/\|/' However, the below awk code is working fine.... (4 Replies)
Discussion started by: royalibrahim
4 Replies

6. Shell Programming and Scripting

sed returns different results while substitution on a pipe delimited file

Hi, Need help with a sed command that I am using to substitute 3 positions of a pipe delimited file. i am getting different results while substituting the same position of two different files with the same value. Please see details below: $ cat chk2 ... (3 Replies)
Discussion started by: vmenon
3 Replies

7. UNIX for Dummies Questions & Answers

Grep char count & pipe to sed command

Hi I am having a 'grep' headache Here is the contents of my file: (PBZ,CP,(((ME,PBZ,BtM),ON),((ME,((PBZ,DG),(CW9,PG11))),CW9,TS2,RT1))) I would like to count out how many times 'PBZ' occurs and then place that number in the line above 3... (8 Replies)
Discussion started by: cavanac2
8 Replies

8. Shell Programming and Scripting

pipe output of grep to sed?

Is there a way I can do this: search for text and replace line containing matched text with a different line? For example: "I want to replace text" I want to search for replace and then change the line to I am perplexed. Hope that makes sense. Thanks in advance. (4 Replies)
Discussion started by: arsh
4 Replies

9. Shell Programming and Scripting

Is it better to grep and pipe to awk, or to seach with awk itself

This may just be a lack of experience talking, but I always assumed that when possible it was better to use a commands built in abilities rather than to pipe to a bunch of commands. I wrote a (very simple) script a while back that was meant to pull out a certain error code, and report back what... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

10. Shell Programming and Scripting

Problem with pipe into sed

Basically I am trying to write a short script to report total space used on /u0? file systems. This is what I was trying to do:df -k /u0? | grep -v kbytes | awk '{ printf $2 "+" }' | sed s/.$// | bcBut it returns no output. This works however: > A=`df -k /u0? |grep -v kbytes | awk '{ printf $2... (2 Replies)
Discussion started by: 98_1LE
2 Replies
Login or Register to Ask a Question