With GNU grep and xargs:
grep -rLZE '.{200}' . | xargs -r0 grep pattern
Alternatively, you could cut the output of grep:
grep -r pattern . | cut -c1-"$COLUMNS"
or tell your terminal not to wrap text if it supports it:
tput rmam
grep -r pattern .
or use less -S
grep -r pattern . | less -S
Since we know where the vin is in the line, we do not need to do a generic search. Instead we can read the vins into a data structure that is indexed to allow fast look ups.
Using Python you can do:
Code:
# read the vins into a set to allow fast lookup
with open('file3', 'rU') as f:
vins = {vin.strip() for vin in f.readlines()}
# go through the data file one line at a time
with open('file2', 'rU') as f:
for line in f.readlines():
# get the vin in the line
vin = line.split(',')[8]
# if the vin is not in our set, print out the line
if vin not in vins:
print(line.strip())
Results:
123,email@example.com,JOE,BLOGGS,123456789,12345-123,"Place Name",12345,1C4NJPBB4DD122174,2014-01-20
123,email@example.com,JOE,BLOGGS,123456789,12345-123,"Place Name",12345,1GMDV33179D147281,2014-01-20
123,email@example.com,JOE,BLOGGS,123456789,12345-123,"Place Name",12345,1FUYDCYB7WP879651,2014-01-20
123,email@example.com,JOE,BLOGGS,123456789,12345-123,"Place Name",12345,5TDBT48A72S003496,2014-01-20
Best Answer
sed
provides a simpler way:This way you delete first occurrence.
If you want more:
, where count of
i
is count of occurrences (one or more, not zero).Multi-line Explanation
In addition
Probably, this variant will work faster, 'cos it reads all rest lines and print them in one time
As result
You can put this code into your
.bashrc
(or config of your shell, if it is other):And use it this way: