2
votes
0answers
69 views

Why can't I redirect grep output to file? [closed]

I am running command like this. # ( ( partclone.restore -X -s some.img -o /dev/sda3 2>&3 ) 3>&1 ) | grep Completed Completed: 0.40% Completed: 1.23% Completed: 2.07% ... ...
0
votes
1answer
32 views

How to filter grep results?

I am new at writing scripts. So I am hoping this is simple. The script I am writing is used to gather system information and save it as an html file. When I run: sudo lshw -short it list all of ...
3
votes
4answers
489 views

Redirect an output to a file from command piping grep

I am running this: cat /dev/urandom|hexdump| grep -i "ffff f" > random and I get nothing in file random, it remains zero length after the command is interrupted. How to make it writing output ...
0
votes
0answers
29 views

Issues with Grep

Why does the bottom line output "0" into the "AD-Results-$month-$Y" file? First grep command fgrep "$month $D $i:" $Filetmp > TempOutput Grep command to read "allows" from tail of ...
0
votes
1answer
46 views

Can someone explain what this grep/cut/awk command is doing

This is inside of a .sh script file: cd /somefolder IP=$(ifconfig | grep 'inet addr:'| grep 168 | grep 192|cut -d: -f2 | awk '{print $1}') The /somefolder has another folder list with a single ...
1
vote
1answer
37 views

Changing current directory to directory that have identifier as the substring

My terminal is currently in the home directory, and the home directory contains a directory which have "round" as the substring. Is there any way to directly change to that directory without typing ...
1
vote
1answer
93 views

Keeping color from vim with grep

I like the way vim highlights the output from syslog. However, I only want the most recent outputs to be opened. I tried grep --color=always "$@" /var/log/syslog > /tmp/fileOUT vim /tmp/fileOUT ...
1
vote
1answer
317 views

Difference between 'grep' in Ubuntu and Kali Linux?

I always used the following command to filter out my contacts email addresses from a directory in Kali Linux: grep -rIhEo "\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+\b" >> 1A I tried ...
4
votes
2answers
699 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
2
votes
1answer
483 views

omit filenames in grep

I am greping a string from multiple files, but the one undesired side effect, is the filename prefacing the output. How can I suppress the filename outputs using only grep? $ grep -i lp lpNet* ...
0
votes
0answers
77 views

Option for GREP only non-default processes and services?

is there any option for grep only non default processes and services? I know how show all of this and export to file, but manual reading and deleting line by line is not ideal. :-) Thanks for your ...
0
votes
1answer
82 views

How would I display the lines that do not have certain letters? [duplicate]

How would I display the lines that do not contain certain letters? This is what I have already tried unsuccessfully to show the lines that do not consist of an a or b: egrep *[^ab]* filename
16
votes
8answers
50k views

How to move multiple files at once to a specific destination directory?

I got a bunch of files in some directory (along with many other files) that I want to move. Luckily, all the files I want to move contain a certain identifier in their names, so I can ls | grep ...
6
votes
2answers
956 views

Grep through subdirectories

Add a string to a text file from terminal I've been looking at this thread. The solution (number 2, with ls grep) works perfectly for files called .txt in the current directory. How about if I wanted ...
11
votes
2answers
16k views

How Do I fetch only the numbers in grep?

I have file like this : other lines . . . blah blah blah (:34) I wish to find the occurrence of numbers in the above file. I came up with : grep [0-9] filename But that is printing the ...
2
votes
4answers
324 views

How do I find matching filenames in a directory listing?

I have bunch of ISO images in my hdd and I have their whole content listed inside a text file in the following format: <immage>.iso, <dir structure>/<filename>.<extension> ...
0
votes
2answers
957 views

How do I copy files that I just searched for via the command line?

Using Ubuntu 12.04 I need help on copying files that were returned from a search with grep . I have many pdf files, so to filter specific named files I am using General grep command as follows. ...
1
vote
1answer
1k views

How can I recursively check folders with flac files for corruption?

Something caused to damage some of my flac files, and to find out which ones I need to rerip, I would like to get a list containing only the damaged files. How I do it now: Open a terminal in a ...
1
vote
3answers
1k views

grep invalid option on ubuntu

I've already removed and reinstalled grep on Ubuntu but still the same error persists. Whatever grep command I type I always see the following output: grep: invalid option -- '=' Usage: grep ...
0
votes
1answer
123 views

How do I grep audio/video frame time indexes from an XML file?

I have a xml file like this: <field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/> <field ...
0
votes
1answer
408 views

Attempting to GREP details of a Java error

I'm running Ubuntu 11 and I'm having some issues with grep. I have a shell script (see below) which essentially checks if a certain Java program of mine is running, if not it runs it. That part works ...
19
votes
2answers
4k views

How does this [t]ricky bracket expression in grep work?

I saw this one-liner recently: $ ps -ef | grep [f]irefox thorsen 16730 1 1 Jun19 ? 00:27:27 /usr/lib/firefox/firefox ... So it seems to return the list of processes with "firefox" ...
0
votes
2answers
303 views

Cat a command to file

My bash script does many things, among which creating another script. I would like to have the following line to be executed from within a script. But it does not work (grep is executed instead of ...
6
votes
2answers
4k views

Is there a way to do a ' ls -R | grep “aname”* | rm; to remove multiple files in multiple directory

I have installed (compiled) emerald. The command make uninstall didn't work (there is no makefile as it is just a script). So I decided to remove the file manually. But there were a lot of files. ...
12
votes
6answers
771 views

How can I grep through tab completion possibilities?

When I press tab in a console I get this output Display all 2957 possibilities? (y or n) Is there any way to use grep on these 2957 possibilities? I would like to search for all commands with ...
9
votes
3answers
7k views

How do I combine multiple grep commands?

I have a command like this: | grep -v @param | grep -v @return | grep -v @Test | grep -v @throws and its getting bigger, is there any way to make this neater?
2
votes
5answers
625 views

How to grep whole manual?

I can do for example man cp | grep verbose to findout if cp man has word "verbose", how can I do something like (pseudo-code) man * | grep copy to find out what command to use for coping?
1
vote
1answer
8k views

How to get line number from grep?

the fallowing grep grep -r -e -n coll * will display fullpath/filename: <tag-name>coll</tag-name> I would like to know what line has the fallowing text, I tried adding -n, but it ...
1
vote
1answer
229 views

bash text processing and error message

for example I have this script that kills firefox ps x | grep firefox | grep -v grep | awk '{print $1}'| xargs kill -9 but when there is no firefox running it spits out: Usage: kill pid ... ...
1
vote
2answers
669 views

how to use grep in a conditional search previous to a sed text replace command

I am trying to change the path in whole lot of m3u files. I know I can do it with regexxer f.e. but I'm trying to learn bash. This is the command I figured out, but it is not working. grep -lr -i -e ...
29
votes
3answers
28k views

How to grep for tabs without using literal tabs and why does \t not work?

When I search for tabs in a file with (e)grep I use the litteral tab (^v + <tab>). I can not utilize \t as a replacement for tabs in regular expressions. With e.g. sed this expression works very ...
2
votes
4answers
197 views

Find and bash problems in recent Ubuntu versions

I've been having a problem the last six months or so when combining searches in bash. The exact example is related to Python programming but would apply to any kind of detection/manipulation. Suppose ...
4
votes
1answer
522 views

Problem manipulating text using grep

I want to search for a line that contains log4j and take 7 lines before and 3 lines after the match. grep -B7 -A3 "log4j" web.xml After that I want to add comment tags before this paragraph and ...
18
votes
2answers
12k views

How to grep 2 or 3 lines, one containing the text I want, and the others just below it?

This is a snapshot of error log: 06:16:29,933 ERROR EmailRMManager$:45 - Exception In get Message com.rabbitmq.client.AlreadyClosedException: clean connection shutdown; reason: Attempt to use closed ...
5
votes
3answers
5k views

using grep with pipe and ampersand to filter errors from find

I am using cygwin to find a file on the cygdrive. However I need to suppress the permission denied messages (otherwise the results get hidden in the error messages). The following command works: ...