Trying to do a grep -v on a value in the 2nd column of text. So if the word apple appears in a line in the 2nd column, it would not show up when the file was cat. Seems like a simple enough operation but I just can't figure it out. Any help would be appreciated. Thanks in advance.
The output would be
Trying to do a grep -v on a value in the 2nd column of text. So if the word apple appears in a line in the 2nd column, it would not show up when the file was cat. Seems like a simple enough operation but I just can't figure it out. Any help would be appreciated. Thanks in advance.
The output would be
It is best if you post a portion of the real text you are working on, instead of a fake imitation. Since your request is inconsistent[*] with the output shown, it is most likely that if someone gives you a solution base on it, you'll come back saying that it doesn't work on your actual text.
* inconsistency:
Quote:
So if the word apple appears in a line in the 2nd column, it would not show up
Quote:
Are pears better for you. Is beer an alternative
What it appears to not show up is a human delineated sentence instead of just the 2nd column
You posted a single line of input. In this single line the second "word" (as per the IBM definition of "word", which is a sequence of nonblank characters delimited by blanks) is "apples". As "grep" works on lines (and lines alone!), the whole line would be either printed or not printed, depending on the regexp you feed it. If you create a regexp matching the second word "apple" (this would be perfectly possible) and you use the "-v" switch to suppress every line matched and print every line not matched, then the output of the single-line input would be empty.
What you want - as indicated by your sample output - is not to work on lines but on sentences. Precisely, you want to remove every sentence which has "apple" as the second word from the input. "Sentence" here means "a sequence of words, followed by a closing punctuation mark (full stop, question mark, exclamation mark, but not colon, comma or semicolon).
Is that so? If yes, we could provide an awk- or sed-script doing this. "grep" will never be able to do this at all.
Gents
Is it possible to update the code to get the desired output files from the input list. I called variable to the first column.
I need to consider the first column as key to grep the values in the second column according to the desired request.
input list
(attached )
output1
... (12 Replies)
I have file that looks like this,
DIP-17571N|refseq:NP_651151 DIP-17460N|refseq:NP_511165|uniprotkb:P45890 DIP-17571N|refseq:NP_651151
DIP-19241N|refseq:NP_524261 DIP-19241N|refseq:NP_524261 DIP-17151N|refseq:NP_524316|uniprotkb:O16797
DIP-19588N|refseq:NP_731165 ... (2 Replies)
Hi have a large spreadsheet which has 4 columns
APM00111803814 server_2 96085 Corp IT Desktop and Apps
APM00111803814 server_2 96085 Corp IT Desktop and Apps
APM00111803814 server_2 96034 Storage Mgmt Team
APM00111803814 server_2 96152 GWP... (6 Replies)
Hi
I have 5 columns like this
a b c d e
f g h i j
k l m n o
From 2nd column till the 5th column of every record, I would like to transpose them as rows, so my output file contains only one row
a
b
c
d
e
f
g
h
i
j (9 Replies)
Hi everyone. I need to change a script (ksh) so that it will grep on the 1st 2 letters in the second column of a 5 column file such as this one:
192.168.1.1 CAXY0_123 10ABFL000001 # Comment
192.168.1.2 CAYZ0_123 10ABTX000002 # Comment
192.168.2.1 FLXY0_123 11ABCA000001 ... (4 Replies)
Hi friends,
My file is like:
Second file is :
I need to print the rows present in file one, but in order present in second file....I used
while read gh;do
awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile
done < secondfile
but the output I am... (14 Replies)
How do I grep/check the on-hand value on the second line of show_prod script below? In this case it's a "3".
So if it's > 0, then run_this, otherwise, quit.
> ./show_prod
Product Status Onhand Price
shoe OK 3 1.1 (6 Replies)
I'm racking my brain on this one! :(
I have a list like this:
Paul 20
Paul 25
Paul 30
Frank 10
Julie 15
Julie 13
etc, etc...
I've been trying to figure out a way to have the output display the name in the first column ONCE and add the numbers in the second column and display that... (2 Replies)