grep is a command-line tool for searching text patterns in files

learn more… | top users | synonyms

-3
votes
1answer
50 views

What command lines should I use for the following? [closed]

What command lines should I use for... printing a list of users running bash now in alphabetical order print the count of users who are running bash right now save the list of users who are running ...
0
votes
3answers
56 views

piped command after grep not working

I want to monitor a file. So I have tailed a file using below command, to execute a script per line. tail -3f logfile.log | grep "action.*add" | sed -u -e "s/^/'/" -e "s/$/'/" | xargs -L 1 -P 5 bash ...
14
votes
5answers
633 views

Find files that contain multiple keywords anywhere in the file

I'm looking for a way to list all files in a directory that contain the full set of keywords I'm seeking, anywhere in the file. So, the keywords need not to appear on the same line. One way to do ...
1
vote
1answer
36 views

Regular Expression ^$ not working on UNIX using grep command

I'm facing a problem in using the regular expression ^$ on UNIX. When I type grep '^hello$' text on the command line, as a result it should match the "hello" word because it is the only word on a ...
4
votes
2answers
8k views

How to grep top most frequent error messages in a unix logfile

If I have a file example apache log file How to extract the top most frequent error messages in a unix log file with no timestamps the key is most frequent error message should come on top of the ...
0
votes
3answers
40 views

Count the number of occurrences of specific number before each string in linux

I have this file : 90 1 120 1 Transition 150 1 Transition 165 1 Transition 180 1 225 1 240 1 255 1 270 1 Transition 285 1 Transition and I want this output: 1 2 2 1 3 1 4 5 5 ...
1
vote
2answers
40 views

Grep from a doubly-gzipped file

I have a file that is gzipped twice: test.gz.gz How do I grep something from the file above? I don't want to unzip it.
2
votes
2answers
89 views

How to Find All .tex Files in Directories in Recurse Grep?

I want to expand the recursive search of symlinks to include only .tex files find . -type l -name "Math*" -exec grep -d "recurse" word {} +. Failed pseudocode 1 find . -type l -name "Math*" \ -exec ...
0
votes
1answer
9 views

How to Limit ContentMatches of Grep in List? [duplicate]

I know the thread here which proposals (... | cut -c 80) however give single letter outputs like n r s t p. I do # http://unix.stackexchange.com/a/293147/16920 find -L $(find . -type l -name 'Math*')...
0
votes
0answers
26 views

Return true or false if files matching wildcard pattern are in a specified directory [duplicate]

I'm trying to adapt some code to return true or false if files matching the *.log pattern exist in the $DIRECTORY variable. I had it returning true or false at the directory level for any files: if ...
0
votes
2answers
56 views

How to grep stderr? [duplicate]

How do I grep this command that includes a wildcard? How do I grep stderr? The grep does not seem to do anything: $ less /Users/raine/.nvm/versions/node/v5.5.0/lib/node_modules/* | grep "Not a file"...
1
vote
1answer
27 views

How to filter the success message when using nc port scan

I used following command for port scanning of my machine nc -zv 192.168.1.1 1-100 but I want to filter only succeeded message from following output.Hence i used the following command nc -zv 192....
2
votes
1answer
430 views

Read from and append to file at the same time while preserving end-of-line

Conceptually I have an easy task... I have [loosely] structured data in a file: Testing: debug, default CXXFLAGS <100's of additional output lines> Testing: release, default CXXFLAGS <100's ...
20
votes
4answers
4k views

Is there a 'rc' configuration file for grep/egrep? (~/.egreprc?)

I usually do some grep when developing, and there are some extensions that I always don't want to look for (like *.pyc). Is it possible to create a ~/.egreprc or something like that, and put some ...
-4
votes
3answers
43 views

Bash - Print lines containing at least all vowels in any order but no consecutives [solved]

The problem is to write a script that takes a file as argument and prints all the lines that contain -at least- all the vowels , -regardless of ordering-, but with [no two same consecutive vowels]. e....
3
votes
3answers
11k views

Why grep doesn't show me the matching word until the next space?

I have a temp file, and I want to grep the only word that matches the pattern instead of whole word. i tried grep -o <pattern> file but its not giving me desired output Input xi29 vddf vss ...
8
votes
4answers
660 views

I need to find all users home directories listed using grep from /etc/passwd

I have a question similar to another one on this site where the individual had to find a list of all users using grep or awk from /etc/passwd. That worked for me but I've tried translating it to find ...
4
votes
2answers
87 views

How Do I Remove Duplicate Words With Suffixes?

How do I compare a list of unsorted words of variable length and remove duplicate words that have a suffix? Example word list: iron curl curled railroad curler ...
3
votes
1answer
29 views

How can I list all layouts and corresponding variants that don't use 3rd level symbols?

I need to list all possible xkb layouts and their respective variants that do not use 3rd-level symbols. Manually review of all files in /usr/share/X11/xkb/symbols/ directory is crazy, there maybe an ...
2
votes
2answers
45 views

Get only the size of a mounted filesystem

I want to get only the total size of a mounted filesystem. But the catch is that I only know about the mount point. So, I thought of using the df command. To get the size of this mounted filesystem, ...
1
vote
2answers
32 views

Generating strings of words with space delimiters from cut statement

I am new to bash. When I run the following command: grep "type" /root/myFile | cut-d'=' -f2 I get the following: 102 304 503 442 I want to store the contents of the first command into a ...
8
votes
5answers
674 views

How to find lines that begin with **

I need to find if any lines in a file begin with ** . I cannot figure out how to do it because * is interpreted as a wildcard by the shell. grep -i "^2" test.out works if the line begins with a 2 ...
-3
votes
2answers
71 views

How can grep for files that end in %0x9

I need to find files ending with the character %0x9. How can I do that?
1
vote
2answers
58 views

Using Grep Command Without Specifying a Certain Directory [closed]

Can you use the grep command without specifying a directory path afterwards? Example: $ sudo grep "filename" / I have also tried this: sudo find / -type f grep -l "filename" Still no luck. ...
5
votes
1answer
291 views

Why won't grep work in this command?

I have GTA San Andreas running in Wine, although when I exit the game it hangs in the terminal, and the process still has leftover resources, which causes it not to exit. So I've made this command ...
1
vote
2answers
57 views

Count the number of lines found by grep

I want to know how many instances of a pattern are found by grep while looking recursively through a directory structure. It seems I should be able to pipe the output of grep through something which ...
0
votes
3answers
24 views

How can I sort specific lines of strings from this file on my Ubuntu Server?

I have a very long file containing around 2,000 groups of information that look like this: http://pastebin.com/raw/vKxRNviT I need to organize them by dollar-balance from highest to lowest. I only ...
0
votes
3answers
78 views

Find-grep for List of .tex Files?

My document.tex where I want to get the list of files, and grep those files with the term gastric \subimport{}{1.2_protocal_answers.tex} \subimport{}{2_protocol_answers.tex} 1.2_protocal_answers....
1
vote
3answers
89 views

Find and Replace with command line

my log.txt file includes ... mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 ... how can I replace mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 with mynetworks = 127.0....
0
votes
1answer
19 views

elinks -dump not finishing on long url

So I have been working on a little script to alert me when an artist releases a new album using amazon and elinks. Problem is that for some reason elinks will stop half way through the -dump command ...
-2
votes
1answer
55 views

filtering pattern in a file using sed or grep

I'm new to Linux. I'd like to store all the unique usernames present in the extended.log file into a new file using the commands awk, grep, and/or sed. The following are the field-names in my file, ...
0
votes
0answers
4k views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
3
votes
2answers
369 views

grep: How to find Closing Bracket?

One part of /usr/share/X11/xkb/symbols/us starts with xkb_symbols "dvorak" { and ends with the closing curly bracket }; which line-number I want to find. partial alphanumeric_keys xkb_symbols "...
-1
votes
1answer
31 views

Read file and write output in another file using shell script

My input file is: Employee e_id e_name 100 abc 101 xyz 102 pqr Salary e_id e_salary 100 12345 101 67890 Dependents e_id depp1 depp2 100 qwer tyui 102 asdf ghjkl I want the output line by line ...
1
vote
2answers
44 views

PGrep in my shell script: not counting the script itself

This is the behavior of pgrep on my FreeBSD script: luis@Balanceador:~/Temporal$ cat test.sh #!/usr/bin/env bash pgrep -fl "test.sh" luis@Balanceador:~/Temporal$ ./test.sh luis@Balanceador:~/...
1
vote
3answers
3k views

Linux: Does find | xargs grep have limitations?

I've historically performed something like: find . 2>/dev/null | xargs grep -i something_to_find 2>/dev/null If my pwd is barfoo (/foo/bar/baz/foofoo/foobar/foobaz/barfoo) it finds matches. ...
4
votes
4answers
51 views

Generate line number / “index” within a range from a date seed value

I'm trying to create a bash script to display a word of the day (random for each day). I have a dictionary file that on each line has a word and its definition. I'd like to use date to get a unique ...
2
votes
2answers
87 views

Grep for dates older than 14 days in a file [duplicate]

I'm trying to find a way to grep how many messages in a file are older than 14 days and have a value of number of results return Example going with today's date of 20160616. $grep 'Put Date' filename:...
0
votes
2answers
329 views

Find line within file matching pattern and make a substitution

I'm trying to simplify my life here but I'm stuck. I have a file containing multiple lines. Each line has a user and a number. I'd like to know a bash one-liner to search for a user and change the ...
1
vote
1answer
44 views

How could I search pattern of one file in to another and save the result of each pattern in new file

I would like to search the patterns of file1 in file2 and the save the result of each pattern in new file. I know how to do do it wiht all the pattern to be search in file 2 and save the results with ...
1
vote
3answers
65 views

grep on interactive program

I have an interactive shell-like program, that outputs a lot of irrelevant error messages, that confuse our customers. Each of these error messages are full-line messages starting with "%". So the ...
3
votes
2answers
75 views

Save the matches of grep as an array

I have a file with the following contents: FILETYPE=A:B:C:D How can I grep out A, B, C and D and save them as an array in a ksh script on Linux? I tried FILETYPES=`grep "FILETYPE" ${CONF_FILE} | ...
1
vote
2answers
35 views

Can anyone explain this expression piece by piece please? grep '\([aeiou]\).\1'

I found this expression for a homework assignment that will "print all lines containing a vowel (a, e, i, o, or u) followed by a single character followed by the same vowel again. Thus, it will find “...
1
vote
1answer
37 views

How to find files their names, name of files are in one file?

I know how to find and concatinate pdf file. I did with the follwoing code. pdfunite *.pdf output.pdf But the problem is I have list of file names in one file say filenames.txt and I would like to ...
11
votes
15answers
3k views

'ls -1' : how to list filenames without extension

ls -1 lists my elements like so: foo.png bar.png foobar.png ... I want it listed without the .png like so: foo bar foobar ... (the dir only contains .png files) Can somebody tell me how to use ...
0
votes
2answers
89 views

how to exclude string that include space by “grep -v” [closed]

I have a script that runs by using bash -c and I want to know how many process are running with that script. $ ps ax | grep my_script_run | grep -v grep | grep -v "bash -c" 11121 ? S 0:00 ...
-2
votes
2answers
66 views

Find all line in a file which start with g or any digit from 0to9

How do I find all lines in a file which start with g or any digit from 0 to 9? Can any one help me using command line? I try and I know how to do if start with g but don't know how to do with g and 0 ...
2
votes
1answer
40 views

Why does grep sometimes return directories with two slashes?

I just ran grep -ri foo someDir/ I got back someDir//foo/bar/baz: onDelete() { Does the double forward slash just mean that everything to the left of it was in the dir argument you provided to ...
1
vote
1answer
32 views

UNIX: excluding patterns, contained in a file, from another file with grep

I have a txt file that contains the patterns I would like to exclude from a file. Is there a way to chain grep -f and grep -v? Thanks
1
vote
0answers
28 views

Find recursively files that have a percentage of lines in common

Is possible to do this? I want an output where i have only files that are 50% the same of others or have 20+ lines in commons. I'm trying to isolate commons functions in *.java files. Thank you!