when i try this awk its giving out put as below.
awk '!(/^$/||/--/||/selected/||/^ *$/){print $1}' tmp.txt
output
1
2010-08-03-12.31.26.126000
how excluede the 1st line ? i mean i want output only 2nd line i.e 2010-08-03-12.31.26.126000;
when i try this awk its giving out put as below.
awk '!(/^$/||/--/||/selected/||/^ *$/){print $1}' tmp.txt
1
2010-08-03-12.31.26.126000
how excluede the 1st line ? i mean i want output only 2nd line i.e 2010-08-03-12.31.26.126000;
... | tail -n+2
awk '!(/^$/||/--/||/selected/||/^ *$/){a=$1} END{print a}' tmp.txt
Print only second line:
awk 'NR==2' infile
Print starting second line:
awk 'NR>1' infile
Considering your first attempt, can you please post a consise input file and expected output?
Fine solution but a pipe to another process isn't really necessary in this case.
This will work but only if there are exactly two matching lines. If there are more, instead of only ignoring the first line, all but the last are discarded.
There's nothing in the problem statement to indicate where the matched lines may occur in the input stream. Unless you're suggesting this as an additional AWK invocation to filter the first's output, in which case, as with the tail approach, it's not necessary.
To exclude the first match, without making any further assumptions, I suggest:
awk '!(/^$/||/--/||/selected/||/^ *$/) && i++ {print $1}' tmp.txt
Regards,
Alister
Or just add another condition...
awk '!(/^$/||/--/||/selected/||/^ *$/||/^.$/) {print $1}' tmp.txt