![]() |
|
|
|
|
|||||||
| 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 |
| Printing out pattern in line | FK_Daemon | Shell Programming and Scripting | 3 | 11-23-2007 01:27 PM |
| Printing a Line from a file | Nysif Steve | UNIX for Dummies Questions & Answers | 4 | 08-31-2007 04:58 AM |
| printing a line number using awk | rjsha1 | Shell Programming and Scripting | 3 | 09-01-2006 06:25 AM |
| Creating a line for printing | jhansrod | Shell Programming and Scripting | 3 | 06-17-2005 02:38 AM |
| Printing line numbers | MizzGail | UNIX for Dummies Questions & Answers | 2 | 07-25-2002 01:18 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
printing the next line too??
Hi, I'm trying to get awk to print every line ending with a colon along with the next line. I have a file like:
Blah Blah a bunch of words, the money things are as follows: Spokane 340,087, 000 3.24500% January 23, 2008 does anyone have any advice on this matter? I'm a bit stumped... Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I forgot to mention that I only want to print the next line if it contains numbers.
Thanks again. |
|
#3
|
|||
|
|||
|
awk
Hi
Try follow code: input: Code:
This is the first line This is the second line: This is the third line This is the forth line: This is the fifth line This is the last line Code:
This is the second line: This is the third line This is the forth line: This is the fifth line Code:
nawk '
/:$/{
print
getline
print
}' filename
|
|
#4
|
|||
|
|||
|
Code:
awk '/:$/{f=1;print;next}f{print;exit}' file
|
|
#5
|
||||
|
||||
|
A SED version of the same
Code:
$ sed -n '/:$/{p;n;p;}' lines.out
|
|
#6
|
||||
|
||||
|
Quote:
Code:
sed -n '/:$/ {N; /[0-9]/ p;}' file
|
|
#7
|
|||
|
|||
|
I think the second line should be printed if it contains a digit, not the every second line
eg cat filename one two three: 1 2 3 four five six 4 5 6 the o/p should be one two three: 1 2 3 |
|||
| Google The UNIX and Linux Forums |