grep question...

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.
Post Reply
ampapa
Know my way around
Posts: 126
Joined: Sat Dec 03, 2011 7:47 am

grep question...

Post by ampapa »

Whenever I try to run a grep from the command line it seems like it just hangs and does nothing... even the most basic command returns no results, is there something I'm missing here???
SNAG-0831.jpg
Anyone know what I'm missing??

Thanks,
You do not have the required permissions to view the files attached to this post.
Thisisnotmyname
Easy as a breeze
Posts: 447
Joined: Mon Nov 19, 2018 1:21 am

Re: grep question...

Post by Thisisnotmyname »

you're not piping anything into the grep so it's attempting to read from standard in (command line). run some other command and pipe the output into the grep.
manguvigo
New here
Posts: 3
Joined: Fri Sep 10, 2021 3:26 am

Re: grep question...

Post by manguvigo »

grep takes the input from a origin (pipe, file, direct input, etc...)

i.e.:

Code: Select all

grep -r "things" * 
(Search the word "things" on all the files recursively from actual folder)

Code: Select all

ls|grep .php
"pipes" the output of ls to the grep command, who only shows the output that contains ".php"

Code: Select all

cat things.txt | grep -v "word" 
Pipes the contain of the file "things.txt" and shows only the lines that DONT have the "word" on them

Look man or grep --help to find more ;)

Some versions of QNAP don't have a full grep implementation, the ARM one I have don't support "-r" :

Code: Select all

[~] # grep -r
grep: invalid option -- 'r'
BusyBox v1.01 (2021.07.25-19:00+0000) multi-call binary

Options:
        -H      prefix output lines with filename where match was found
        -h      suppress the prefixing filename on output
        -i      ignore case distinctions
        -l      list names of files that match
        -n      print line number with output lines
        -q      be quiet. Returns 0 if result was found, 1 otherwise
        -v      select non-matching lines
        -s      suppress file open/read error messages
ampapa
Know my way around
Posts: 126
Joined: Sat Dec 03, 2011 7:47 am

Re: grep question...

Post by ampapa »

There is no option for -r in this version or what is installed on the QNAP...

I'm trying to find files containing the letter "a"... output to the screen is fine
SNAG-0832.jpg
You do not have the required permissions to view the files attached to this post.
ampapa
Know my way around
Posts: 126
Joined: Sat Dec 03, 2011 7:47 am

Re: grep question...

Post by ampapa »

Just following up here... grep in a stripped down version used in my QNAP doesn't appear to have a recursive function... odd.

grep seems to work...
SNAG-0834.jpg
Anyone have any ideas for recursively scanning test in files???
You do not have the required permissions to view the files attached to this post.
ampapa
Know my way around
Posts: 126
Joined: Sat Dec 03, 2011 7:47 am

Re: grep question...

Post by ampapa »

Just closing the loop here... egrep is fully functional. I've moved away from grep.

Thanks,
Post Reply

Return to “Miscellaneous”