Cut line from searched file if grep find neighbor columns
Hello All,
While searching for the question, I found some answers but my implementation is not giving expected output.
I have two files; one is sourcefile, other is named template.
What I want to do is to search each line in template, when found all columns, cut the matching line from source file.
Print order is important. I have tested another script but it gives the output in alphabetical order which I do not desire.
If column1 and column2 in template file are not neighbor in sourcefile, I wish the script to skip that line. Max column nr is: 5
sourcefile
template
Expected output with below order:
Tested script:
I'd like to know how to manage this process.
Thanks
Boris
Last edited by baris35; 12-06-2018 at 04:33 PM..
Reason: paste error on expected output
I am having trouble matching *two* strings from one file anywhere in a line of a second file, and could use some help getting this figured out. My preference would be to use grep for this because I would like to take advantage of its -A option. The latter is due to the fact that I would like both... (2 Replies)
How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases?
This would seem to involve find, xargs, *grep, regex, etc.
In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
Hi,
I have one input file with the following content:
MY_inpfile.txt
Aname1 Cname1 Cname2 1808 5
Aname2 Cname1 1802 47
Bname1 ? 1819 22
Bname2 Cname1 1784 11
Bname3 1817 9
Zname1 Cname1 1805 59
Zname2 Cname1 Cname2 Cname3 1797 27
Every line in my input file have a 4 digit... (5 Replies)
Hi,
I am working on one script..I am having files in the below format
file 1 (each line is separated with : delimeter)
SPLASH:SPLASH:SVN
CIB/MCH:MCH:SVN
Now I want from file 1 that most left part of the first line will store in... (6 Replies)
not sure how to do it. wan't to delete it using cut and grep ince i would use it in the shell.
but how must the command be?
grep "64.233.181.103 wwwGoogle.com" /etc/hosts | cut -d
the delimeter is just a space. can you help meplease. :D (1 Reply)
Hi,
Can anbody please let me know how i can retrieve lines above the line being searched in a file.
I am looking for an error message from a file, if I see that message I want the lines above that message along with this line.
how do we do this.
Please do let me know
An example which i have... (2 Replies)
i have to grep a file which has contents like
/Source/value/valuefile/readme.txt DefaultVersion:=1.7
I have to grep this file with "/Source/value/valuefile/readme.txt" and cut the corresponding value "1.7" from the same line
i tried grep and cut but not working. (1 Reply)
What I need to do is: I need to use the grep command to search for pattern in directory and sub-directories. And also I need to show the permission of file been seached by the grep command.
Could any one please suggest me?
-----------------
$> cat file1.txt
A
-----------------... (8 Replies)
Hi all,
Would like to know how I could search for a string 'xyz' but have the output show the line plus the line above and/or below all lines found.
eg. search for xyz from file containing:
abc
12345
asdf xyz asdfds
wwwww
kjkjkj
ppppp
kkkxyz
eeee
zzzzz
and the output to... (2 Replies)
I need to grep and cut the some file in the folder and output to some file.
the sample file looks like below
-rw-r--r-- 1 gui gui 28050789 Jun 25 18:38 mymkzpiii.txt
-rw-r--r-- 1 gui gui 127983856 Jun 25 18:39 phmnlpiii.txt
i need the output like below
... (3 Replies)