This example shows how you can store the lines in an array. The for loop in the END section loops through the array and prints the lines that match the pattern.
Hi All,
Is there a way to save a range in variable for later printing?
for example write somthing like this:
awk '
/pattern1/,/pattern2/{f=range}
/pattern3/{print f}
'
I don't know excatly what "range" could be but is there a way to do this? (8 Replies)
Hello,
I am obviously quite new to unix and awk. I need to parse certain columns of a file (delimited by spaces), and somehow save the value of this column somewhere, together with the value of the column just after it (by pairs; so something like ).
I'm then supposed to count the times that... (9 Replies)
Hi guys!
I'm new to scripting and I need to write a script in awk.
Here is example of file on which I'm working
ATOM 4688 HG1 PRO A 322 18.080 59.680 137.020 1.00 0.00
ATOM 4689 HG2 PRO A 322 18.850 61.220 137.010 1.00 0.00
ATOM 4690 CD ... (18 Replies)
I have a directory question where I ask the user which entry he wants to delete...
echo "Which entry?"
read entry
sed '/^'$entry'/d' file
This code does in fact delete that particular entry...
HOWEVER, when I go to inquire about that same entry, it still populates like it was never... (4 Replies)
Hello,
I was wondering how is it possible if I use this command:
awk 'NR >= 998 && NR <= 1000' file.txtTo exit after parsing the 1000th line ( last line targeted) ???
I observed that when executing this command for a large file, if the range of lines is at the beginning of the file it is... (2 Replies)
My source file is structured with two words on each line
word1 word2
word1 word2
I am using sed and awk to grab groups of specific lines
line=`awk 'NR>=4 && NR<=7' file1`; echo $line
line=` sed -n '1,5'p file1`; echo $line
The resulting output is
word1 word2 word1 word2 word1... (1 Reply)
Say you want to clear your .bash_history except for the first 25 lines. Try:
sed -i -e 26,500d .bash_historyI have a some frequently-used routines parked in the first few lines, and they kept getting overwritten by more recent commands. (2 Replies)
Discussion started by: Xubuntu56
2 Replies
LEARN ABOUT V7
uniq
UNIQ(1) General Commands Manual UNIQ(1)NAME
uniq - report repeated lines in a file
SYNOPSIS
uniq [ -udc [ +n ] [ -n ] ] [ input [ output ] ]
DESCRIPTION
Uniq reads the input file comparing adjacent lines. In the normal case, the second and succeeding copies of repeated lines are removed;
the remainder is written on the output file. Note that repeated lines must be adjacent in order to be found; see sort(1). If the -u flag
is used, just the lines that are not repeated in the original file are output. The -d option specifies that one copy of just the repeated
lines is to be written. The normal mode output is the union of the -u and -d mode outputs.
The -c option supersedes -u and -d and generates an output report in default style but with each line preceded by a count of the number of
times it occurred.
The n arguments specify skipping an initial portion of each line in the comparison:
-n The first n fields together with any blanks before each are ignored. A field is defined as a string of non-space, non-tab charac-
ters separated by tabs and spaces from its neighbors.
+n The first n characters are ignored. Fields are skipped before characters.
SEE ALSO sort(1), comm(1)UNIQ(1)