New answers tagged

0

Have you tried wget --nc? -nc, --no-clobber: skip downloads that would download to existing files. (http://stackoverflow.com/questions/4944295/skip-download-if-files-exist-in-wget)


2

Questions 1 and 3 are related and can be answered at a time. As per the grep man page (emphasis mine): --exclude-dir=DIR Exclude directories matching the pattern DIR from recursive searches. So basically what you specify with that option is a pattern and not a directory itself, meaning /var/www/sometext* or even /var/www/sometext/* will expand and ...


0

To transliterate all uppercase characters in a file to lowercase on a Unix system, use the tr utility like this: $ tr 'A-Z' 'a-z' <inputfile >outputfile


0

If you're getting errors about permissions (you don't say you do), then I'm guessing you're standing in either the root directory (/) or in some path where you don't have permission to read all files, such as in /etc or in /var. But since you say it takes an awfully long time, I'm leaning more towards the first assumption (the root directory). If you want ...


-1

grep file1.txt file2.txt -e expr has grep opening the files itself, so -H will still work.


1

If you have GNU grep, the grep itself supports "-r" option to search recursively, as suggested by @Ouroborus. If unfortunately your grep does not support such option, like in SunOS, you can use following commands instead: find . -name "*.txt" -exec grep -n your_pattern {} /dev/null \; The tricky is /dev/null added to ensure each execution of grep has two ...


0

As in this answer, you're probably better off with: grep -rnw '/path/to/somewhere/' -e "pattern" -r or -R is recursive, -n is line number, and -w stands match the whole word. -l (lower-case L) can be added to just give the file name of matching files.


0

This turned out to be a combination of problems. (echo true& echo true2) actually outputs the following on a Windows machine: true \r\n true2 \r\n So the first issue is that my regular expression was missing a space character. The second issue is that grep treats \n as the end of the line, which is explained in an answer to Why is the end-of-line $ ...


2

Cygwin: (echo true; echo true2) | grep true$ GnuWin:(echo true & echo true2) | grep "true $" In cmd, (echo true & echo true2) actually gives true \r\ntrue2\r\n


1

Since you are going to grep the file content, -l listing the zip file won't be enough. you need to actually unzip it. so: temp=`mktemp -d` find . -iname '*.zip' -print -exec unzip -d $temp {} \; 2> error.txt grep -ir vbs $temp


1

Those additional lines are probably in the stderr stream. You could test by seeing if they redirect out to a separate file (e.g. command 2> error.txt) Basically, run: find . -iname '*.zip' -print -exec unzip -l {} \; 2> error.txt |grep -i vbs If this fixes your problem, you can replace error.txt with /dev/null (this may not work on all versions of ...


0

I would suggest using busybox-w32 from https://frippery.org/busybox/, since it is only 5xxKB in size and actively maintained. so that in your case, in the command prompt, it is busybox ls | busybox grep root you can use doskey in command prompt launch by a batch file to make command, like doskey ls="path\to\busybox.exe" ls $* doskey grep="path\to\...


0

I found the answer, You can use Extended Grep like: ls --help | egrep '<pattern>|' Like- ls --help | egrep 'F|' Notice the pipe at the end. Alternately, you can use grep -E This answer was originally posted at: http://stackoverflow.com/a/28210153/2095777


2

The occurrence that you want is not the second occurrence; it is the third. To get the third occurrence of -c with three lines of context: $ man sh | awk '/-c/{n++; if (n==3)f=3;} f{print;f--;}' -c Read commands from the command_string operand instead of from the standard input. Special param‐ eter 0 ...


1

grep -ril 'string 1' * | xargs grep -rin 'string 2' The -l includes only file names rather than the matching lines themselves. The xargs reads the files to search from the standard output of the first grep.


1

You're doing a relational "join" operation, so use the standard UNIX join command: $ join fileA.txt fileB.txt 4 text3 5 text4 8 text7 9 text8 To only get the second field from the second file, add -o 2.2: $ join -o 2.2 fileA.txt fileB.txt text3 text4 text7 text8 Both files needs to be sorted on the join field (the first column in this example) for this ...


1

$ awk 'FNR==NR{seen[$1];next;} FNR in seen' FileA FileB text3 text4 text7 text8 How it works FNR==NR{seen[$1];next;} While reading the first file, this adds each number as a keey to the associative array seen. FNR is the line number of the current file and NR is the line number among all lines read. So when FNR==NR, then we are still reading the first ...


1

You can create a simple sed script from the file A by appending p to each line, then run the script in another sed with -n not to print the other lines. Moreover, there's no need to save the generated script, you can pipe it between the seds: sed 's/$/p/' A | sed -nf- B



Top 50 recent answers are included