I'm trying to do two things at once with a grep command. Basically, I have a file like this:
What I want to do is use grep or some similar utility so I can grab all lines that start with ##, but without the pound signs. My output would be:Code:something ##matching line 1 ##matching line 2 ###matching line 3 stuff that won't match
I know I want something like the inverse of the -o option, i.e. printing out the part of each matching line that didn't match. Does anyone know how to do this in any way?Code:matching line 1 matching line 2 #matching line 3
sudo rm -rf /
That works great! Thanks. I had no idea cut existed. I also found another way, slightly shorter:
Code:grep '##' file | cut -c 3-
sudo rm -rf /
I don't know a lot about Unix, but if there is a program that can take text as input and delete certain characters, you could pipe grep's output into that.
That would be cut.
sudo rm -rf /
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks