All Questions

Tagged with
0
votes
2answers
38 views

How can pass the stdout to the last comand?

I am trying a search with locate only in the current directory, for do this I am using the following approach: locate file | pwd | xargs grep the problem is that the locate results are lost into a ...
0
votes
2answers
38 views

xargs issue with grepped files containing spaces

I have a range of .html files all containing spaces in between. What I need is to locate the file using find in conjunction with grep, and if a match is found, basically I just want xargs to open it ...
0
votes
1answer
27 views

If $x represent column where x is 1..any what represents rows in bash

Team, i need to know how to operate on value row wise after performing grep. I can operate column wise using $ but how to on row value? my output is cat file.txt | grep -o 'test1[^. ]*' output: ...
1
vote
0answers
89 views

How to improve this 'sed' search & replace command?

How to search and replace recursively through multiple files in a directory, using essential tools installed in mostly any Debian/Ubuntu machine? There are multiple answers in Stack* where to find ...
10
votes
4answers
2k views

Move all files NOT ending with .txt [duplicate]

In the directory /home/username/data I have both files and directories. Some of these filenames end in .txt (to which I'll refer as text files), others don't. The same happens in the subdirectories. ...
0
votes
1answer
57 views

xargs vertical alignment of output

I want to extract certain values from files in many subdirectories. I have a working code that does this: for i in */; do grep "free energy" "$i"filename | tail -1 | xargs -I{} echo "$i: {}" >>...
0
votes
1answer
27 views

Distinguish a command not a native second transmitter

suppose [root@iz2ze9wve43n2nyuvmsfx5z /]# find . -maxdepth 2 -type d | ls bin dev home lib64 media opt root sbin sys usr boot etc lib lost+found mnt proc run srv tmp ...
0
votes
2answers
676 views

Using regular expression for rm and ls

QUESTION: What is happening here and how do I fix it? PROBLEM: When I do: $ls | grep -P "file[1-9]{3}.txt|file[1-9]{2}.txt" I get: file11.txt file12.txt file13.txt file14.txt file15.txt file16....
0
votes
2answers
71 views

Converting a working command into shell script file which gets arguments

Hi my working command is: grep -l "my text" file*.ext|xargs ls -lart this command is very useful for me and I wanted to create a shell file which does it with fewer typing, like this: fn "my text" ...
1
vote
4answers
798 views

Skip first line from output of each iteration of XARGS

cut -d, -f2 parsed_repayment.csv | uniq -d | xargs -n1 -I{} grep {} parsed_repayment.csv | wc -l I basically want to skip the first match for each grep command and write them to a file, but xargs ...
-1
votes
3answers
168 views

How to use grep and/or awk to select multiple pathnames in file and remove those files?

I have some output that is formatted like so: foo: /some/long/path_with_underscores-and-hyphens/andnumbers1.ext exists in filesystem foo: /another/one.ext exists in filesystem bar: /another/path/and/...
1
vote
1answer
262 views

git checkout specific files

In the moment, when I run git status, I got modified: loanwolf/alerts/locale/fr/LC_MESSAGES/django.mo modified: loanwolf/alerts/locale/fr/LC_MESSAGES/django.po modified: loanwolf/clientspace/...
0
votes
1answer
48 views

How to find occurance of mxprod|nlsoprdc inside multiple file in a directory? [duplicate]

How can I: Search for a particular pattern in the content of files in a directory and its subdirectory And list the filename if it has particular pattern?
3
votes
3answers
2k views

Get the filename after find -name | xargs

I've a multiple jar directory in which I would like to locate some classes. I found a solution to see if a Class exists with the following command : find -name "*.jar" | xargs -n 1 jar tf | grep '...
1
vote
1answer
236 views

Output file content with grep along with directory name

I have something like a tree structure of directories, with some of them having inside a file named "Filename". Inside each of these files, there is some information that I would like to access after ...
-1
votes
1answer
555 views

grep pattern syntax [closed]

i have a file with names which i make with three files. i want grep 0 if the pattern is absent from any file and 1 if the pattern is present i am using this command cat X.nam |xargs -i grep -c -P '{}$...
5
votes
5answers
3k views

One liner to see if grep returned something? [duplicate]

I'm trying to check if a machine is a ThinkPad or not using something like this: sudo dmidecode | grep ThinkPad I want the end result return true or false (or 1/0). I'm thinking the solution might ...
1
vote
1answer
1k views

find … | xargs grep --> colors missing for output of grep [duplicate]

This way I get colored output: grep class testdata.py Since this gets set in my .bashrc: alias grep='grep -n --color' But if I search like this, I see no colored output: find -name '*.py' | ...
6
votes
3answers
5k views

ssh-add add all private keys in .ssh directory

In my day-to-day, I need to ssh to various machines, all of which I have a different private key for. When I start a new shell session - only my default id_rsa is added to the ssh key chain - I have ...
1
vote
3answers
589 views

Search for a string in a file and rename multiple files to the results

I am attempting to recursively search through a list of files and if the file contains a string, rename the file to the grep results of said string. The sample files contain a the following content: ...
4
votes
1answer
1k views

GNU parallel excessively slow

I need to run grep on a couple of million files. Therefore I tried to speed it up, following the two approaches mentioned here: xargs -P -n and GNU parallel. I tried this on a subset of my files (9026 ...
1
vote
1answer
239 views

Why does piping filenames into VIM break bash when I return to the shell?

I searched for a few files with find and I wanted to open all of them in tabs in Vim. So I tried this: find . | xargs fgrep -l myExpression | xargs vim -p This worked great, except when I was done ...
1
vote
2answers
422 views

use find and grep to find lines that contain some string and don't contain other string from files

First, I try the following code find . -name "*.cfg" | xargs grep "good"|grep -v "^\#" In the current folder, I get the list with the file name's extension is "cfg". Then I want to search the ...
1
vote
0answers
100 views

Chaining grep commands [duplicate]

I'd like to find all xml files containing 'foo', but not containing 'bar'. The command I've put together looks like this: find -iname "*.xml" -print0 | xargs -0 grep -FlisZ "foo" | xargs -0 grep -...
0
votes
2answers
395 views

Find, xargs and grep combination throws an error

The command which throws the error: $ find /mydir/tmp/*20151014* -print | xargs grep -l 'filesTransmitted=1' bash: /usr/bin/find: The parameter or environment lists are too long. Is there any ...
8
votes
2answers
2k views

Unset all ENV variables matching _PROXY

I'm trying to unset all environment variables that match _PROXY: env | grep -i _proxy | column -t -s '=' | awk '{ print $1 }' | grep -iv 'no_proxy' | xargs -0 -I variable unset variable but it's ...
3
votes
3answers
173 views

Search a String in a directory- Get output without filename

I am executing the below command to display the lines which matches the pattern. find ./files/ -name "*.txt" -print0 | xargs -0 grep "5|20150507" And output is ./files/N1.942_0000.txt:78787878|...
8
votes
4answers
26k views

How do I perform xargs grep on grep output that has spaces?

I'm searching for files based on a regular expression, and then I'm trying to search those files for content. So, for example, I have something like #Find all C++ files that match a certain pattern ...
1
vote
2answers
709 views

Seaching a File in Unix for a given string and then another set of Strings within this file and print file properties too

I am using command to search for files staring from a given Directory in Unix , files ending *.sas and containing the string DB2. I then inturn want to search the resultant set of files for the ...
2
votes
4answers
2k views

grep for files and open the resultant matches

I'm trying to open all files based on some return values from grep in the command line. I know that I can use the -l option to only return filenames, but I would like to combine this somehow with ...
7
votes
3answers
638 views

Is there a way to make this one-liner faster?

Context I have a directory of thousands of zip files that are dated in the form YYYYMMDD_hhmmss.zip and each about 300K. Within each zip file is about 400 xml files each about 3K. The problem I ...
5
votes
2answers
2k views

Blank lines when executing “grep | xargs” in a “find -exec”

I'm trying to list all directories of a web server that are blocked by Apache via a .htaccess (containing deny from all). I've managed to get the list of blocking .htaccess but when I try to extract ...
2
votes
4answers
2k views

Zgrep stop after first match when arguments are passed from xargs

I'm using this command to find patterns in zip files (similar to the one) suggested here https://superuser.com/questions/144926/unix-grep-for-a-string-within-all-gzip-files-in-all-subdirectories ...
2
votes
4answers
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
3answers
2k views

Use command grep and locate

How I can make the grep command locate certain words in the files specified by the routes found by the locate command? locate my.cnf | grep user (I want that grep command search the word "user" ...
3
votes
3answers
10k views

How can I pass strings with single quotes to grep?

My desired outcome is the following: to recursively search a directory looking for a given string in all found files. The following command is my usual port of call: find ./ | xargs grep -ns 'foobar' ...
12
votes
2answers
42k views

using xargs to grep multiple patterns

I have a file that has terms I want to grep for, with each term being one line in the file. I was thinking I could do this with xargs. What I'm able to glean from examples from the man page like this ...
2
votes
2answers
999 views

xargs grep suggestion

grep -v "\<Swap" instruments.log | awk '{ idx=index($0, "MasterId="); masterId=substr($0, idx+length("MasterId=")+1); masterId=substr(masterId,1,index(masterId,"L")-3); print masterId; }' | xargs ...
4
votes
6answers
4k views

Grep a directory and return list with line numbers

I'm currently trying to learn more about bash scripting and all of that fun stuff, and I pieced together this little command: find $path | xargs grep -n $pattern | awk '{print $1}' While this DOES ...
14
votes
6answers
105k views

How to search for a word in entire content of a directory in linux

need to search for something in entire content I am trying: find . | xargs grep word I get error: xargs: unterminated quote How to achieve this?
16
votes
3answers
5k views

bash find xargs grep only single occurence

Maybe it's a bit strange - and maybe there are other tools to do this but, well.. I am using the following classic bash command to find all files which contain some string: find . -type f | xargs ...