1
vote
1answer
51 views

How do I pipe output to date -d “value”?

I have a date like "2014-01-30 05:04:27 GMT", and if I run date -d "2014-01-30 05:04:27 GMT", the output is in my server's timezone ("Thu Jan 30 16:04:27 EST 2014"). With the use of grep and cut, I ...
0
votes
2answers
67 views

How to redirect a part of stderr and stdout to /dev/null

My program outputs to stderr and stdout. I want to grep for "pattern" either in stderr and stdout. And I want the rest to be sent to /dev/null. If I pipe after redirect stderr : ./prog 2>/dev/null ...
3
votes
2answers
63 views

Sort files with grep

I have a few hundreds of output files, of which some contain error messages. Lets say I want to automatically put all files containing the string "ERROR_1" in a "subfolder_1", and the rest in a second ...
0
votes
1answer
216 views

Running pdfcrack to include special characters in charset

I'm trying to recover a password from a PDF file using pdfcrack. I want to change the charset to include special characters. Can I use some kind of i/o redirect to feed the contents of a a similiar ...
1
vote
1answer
235 views

grep with colored output returns several empty lines

I have strange issue with grep (2.12-2, debian testing). In some situations when I do something like this: grep -rni '."spacer">.' . grep return me several empty lines: If I add --color=none ...
1
vote
2answers
81 views

Finding folders only

My harddrive is in a mess, so I decided to do a cleanup. As a part of this, I want to merge all folders containing music into one. What I want to do is, look for any *.mp3's and *.aac's on my drive ...
0
votes
2answers
166 views

Why cat $(find /usr/portage -name *.ebuild) | grep RESTRICT - works? And find | grep - not?

Why I can't grep find? Only helps grepping cat of find. As I see program grep could see some context in which every command runs. But it's counterintuitive for a newbie like me. When given with ...
0
votes
1answer
170 views

Pipe multiple commands to single grep

I'd like pipe the output of multiple commands to a single grep. Example: I'd like to combine these two lines: smartctl -A /dev/sda | grep -e Reallocated_Event_Count -e Current_Pending_Sector ...
3
votes
2answers
336 views

How can I retain grep's match highlighting when piping find into grep?

If I run grep foo bar.txt, grep highlights each occurrence of "foo" in bar.txt. But sometimes I want to use find to determine which files grep searches. So I do something like this: find . -iname ...
0
votes
1answer
374 views

How to find the last match of a string in a bunch of files

I have a bunch of files, I'd like to find the last match of a string in each of them. grep text *.file gives me all the matches not the last ones. ls *.file | xargs grep text | tail -n 1 gives me ...
0
votes
1answer
634 views

“find | grep | awk” fails miserabily

I'm scanning for all shell scripts on my server, and are doing this by the following command: find / -type f -exec file --mime-type {} \; | grep "text/x-shellscript" This is working fine, and here ...
3
votes
3answers
2k views

How can I grep in source files for some text?

At the moment I'm using two commands, I'm sure there must be a better way... wim@wim-acer:~/ffmpeg$ find . -name "*.h" -print0 | xargs -0 grep -i invalid\ preset wim@wim-acer:~/ffmpeg$ find . -name ...
1
vote
2answers
2k views

How to feed grep output into scp?

I have a file where each line is a file name. Content of the file: file1 file2 file3 ... I then run a grep command to get a subset of the list of the file names. How do I feed the output of the ...
9
votes
7answers
5k views

Advantages of cat'ing file and piping to grep

Are there any additional advantages of cat'ing a file and piping it to grep, besides convenience? The convenience being that, when I retrieve commands such as those below from my history, the cursor ...
0
votes
3answers
462 views

How do I run a command on each file within a directory that matches a pattern?

I'm trying to run a command on every file within a directory (recursively) that matches a pattern. I need the filename of each item that matches for the command however. This is how far I've got: ...
2
votes
1answer
974 views

Pipe grep exit code away

When I need to suppress some kind of output e.g. foo | grep -v bar But foo gives sometimes only: bar bar bar... grep will return -1. How do I transform the exit code 1 to 0?
1
vote
1answer
551 views

grep -v -A not working properly (actually not working at all)

I have to filter lines like the following: [javac] /Users/looris/Sviluppo/android/projects/toutry/src/net/looris/toutry/Stuff.java:23: warning: unmappable character for encoding ascii [javac] ...
0
votes
2answers
852 views

Grepping grep output fails

I'm trying to grep the output of ngrep. Unfortunately when I add another grep to the pipeline, I get no output at all. It can be some other command too - cat / grep / tee - everything breaks the ...
73
votes
4answers
15k views

Less and Grep: Getting colored results when using a pipe from grep to less

I use the --colour option of grep a lot, but I often use less as well. How can I pipe grep results to less and still preserve the coloring. (Or is that possible?) grep "search-string" -R * --colour | ...