4
rated 0 times
[
4]
[
0]
/ answers: 1 / hits: 487
/ 2 Years ago, fri, july 22, 2022, 4:10:37
For example I have a directory:
/A/B/C/D/E/F/G.txt
Not knowing a priori /E/F/G.txt
, I need to isolate that part. For ease of example:
echo '/A/B/C/D/E/F/G.txt' | grep -o '/A/B/C/D'
Shows:
/A/B/C/D
But I want:
/E/F/G.txt
With:
echo '/A/B/C/D/E/F/G.txt' | grep -o -v '/A/B/C/D'
I don't get the desired output (the output is not there at all).
How can I get the desired output using grep
, i.e. not showing the part of the line which is in the search terms of grep
?
More From » command-line