Yet another pointless discussion thread...

Talk about anything you feel like talking about. Pull up a soapbox and pontificate to your heart's content. May contain some adult humour or otherwise objectionable content (NSFW). No warez, pr0n or illegal stuff.

Re: Yet another pointless discussion thread...

Postby Randicus Draco Albus » November 13th, 2018, 10:41 pm

nodir wrote:Never saw: grep -R .
I had to ask what it does. Don't ask what it does. No one will like you anymore. You have been warned.

probably an arch-ism, aka show off.

I do not know about Linux, but OpenBSD's man page for grep has
Code: Select all
 -R      Recursively search subdirectories listed.
I have no idea how useful it is, but it is there. I have never gotten deep enough into command line research to learn more than what grep does. :oops:
Klingons are fun, but Romulans are the sexiest women in the galaxy.
User avatar
Randicus Draco Albus
 
Posts: 1497
Joined: September 22nd, 2011, 1:22 pm

Re: Yet another pointless discussion thread...

Postby nodir » November 13th, 2018, 10:47 pm

Randicus: assuming the folks i asked are right, and i am pretty sure you can always rely on them, then it is (again) a bashism. So you find the answer in a BSD manpage ...
If you use -r or -R (which kinda doesn't make any sense here, as long gnu grep is used), then it will assume the current directory as the directory to search, so . is the pattern (also known as: anything, well, more or less), the missing directory is pwd.
To make it short: the command lists the contents of all files in the current directory.
If there only was another command to do such ...
:-)
The last few weeks i had to grep recursively quite a bit. directory with the dragora recipes, and, example, i forgot which recipes use cmake and i quickly want to find at least one of them, to have a cmake template. grep -r cmake recipes. In all those years before i never needed it (and perhaps there is even a better solution, i sure don't know)

As an BSD'ler you will love that:
I don't know whether you're asking a question that you want answee
red, or using a rhetorical construct to answer something.
...
It does? That's idiocy. Why would... meh, it's GNU. Why ask whh
y.
...
Can you use an actual, non-broken command in your next question pp
lease? So we don't have to work out whether you're
asking about a bug in a GNU program or what.
...

And so forth.
Well: i survived it. But they sure gave me hard times.
My summary of getting quite a bit of flame:
k, thanks all, i will move that to the garbage can of my brain.


I hope that was clear, more or less. Else just forget about it.
Moral of the story? If i have no clue about something and have to investigate, then i don't make it sound as if it was the most natural thing for me since jesus was a baby.
Last edited by nodir on November 13th, 2018, 11:00 pm, edited 3 times in total.
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby nodir » November 13th, 2018, 10:52 pm

-r, --recursive
Read all files under each directory, recursively, following
symbolic links only if they are on the command line. *** Note that
if no file operand is given, grep searches the working
directory. *** This is equivalent to the -d recurse option.

^^ plain words.
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby Head_on_a_Stick » November 13th, 2018, 11:02 pm

nodir wrote:If you use -r or -R (which kinda doesn't make any sense here, as long gnu grep is used), then it will assume the current directory as the directory to search, so . is the pattern (also known as: anything, well, more or less), the missing directory is pwd.

Not quite: I didn't supply a search pattern so `grep` just listed everything in the current directory (as specified by the dot), recursively.

-R differs from -r in that it will also search symlinks.

nodir wrote:If there only was another command to do such ...

I suppose I could have used `cat *` or suchlike but grep gives the filename (in red if colour is enabled) before the contents and the file name describes the vulnerability to which the protections listed apply.
Show Off
User avatar
Head_on_a_Stick
 
Posts: 163
Joined: June 16th, 2015, 8:35 pm
Location: London baby!

Re: Yet another pointless discussion thread...

Postby nodir » November 13th, 2018, 11:08 pm

nope, you are wrong there.
just do : grep -R /path/to/file
No nothing, but an error. . is the search pattern, path is taken as default if no path is given.
Next try.

filename you want, huh? If only that was possible: for i in ./*; do printf "%s: " "$i"; cat "$i"; done

I and anyone who wants to, including you, can read what gnu man grep says bout -R. Thing is: there are no symlinks.

Just ask people with a clue, and they will give you all their loving. It's crap (and as you have just proofed, you don't even understand what you copied and pasted from someone who has no clue either).
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby Randicus Draco Albus » November 13th, 2018, 11:32 pm

nodir wrote:If you use -r or -R (which kinda doesn't make any sense here, as long gnu grep is used), then it will assume the current directory as the directory to search, so . is the pattern (also known as: anything, well, more or less), the missing directory is pwd.
To make it short: the command lists the contents of all files in the current directory.

In other words it is redundant. Thanks. I learned something today.
Klingons are fun, but Romulans are the sexiest women in the galaxy.
User avatar
Randicus Draco Albus
 
Posts: 1497
Joined: September 22nd, 2011, 1:22 pm

Re: Yet another pointless discussion thread...

Postby nodir » November 13th, 2018, 11:38 pm

don't take my word for it. I never saw such before, and only said what i was told.
Better ask people who know such in and out (as said: as far i undertood it's a bashism, so no luck in your world).

I for one always prefer a solution i can undertand, someone else can understand, both now and in the future, and which is plain an simple.
while :; instead of while true;
or for i; instead of for i in "$@"
are not my thing. To give more examples, where saving a wee bit of space makes it much harder to understand.
Whenever i run in Arch people: they do it exactly the other way around.
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby Randicus Draco Albus » November 14th, 2018, 12:05 am

It makes sense. The -R option is "recursively". rm -R for example. So if grep lists files in "the current directory", then the recursive option would be redundant. Seems logical. Perhaps it was originally used for something that was removed or intended for something that was never developed? Or bash developers may simply include the same options with every command regardless of their usefulness. A template where some options may not do anything with some commands, but will not break anything.

I am full of ideas today.
Klingons are fun, but Romulans are the sexiest women in the galaxy.
User avatar
Randicus Draco Albus
 
Posts: 1497
Joined: September 22nd, 2011, 1:22 pm

Re: Yet another pointless discussion thread...

Postby nodir » November 14th, 2018, 12:57 am

-r or -R makes sense (the latter if symlinks are involved).
What doesn't make much sense is to omit the path where to grep (or the pattern, as stick-in-the-ass wants to believe. Same problem anyway). grep pattern filename. It's clear. It's easy. It's good. grep -r pattern path. Same story. Even if you never used -r before, you sure once ran in recursively as -r, you know how grep works, you can make sense of it. Quite some very experienced bash and all kind of other shells users were confused more than just a bit by the fuck used above. That's why i call it a show off. It doesn't add *anything*, and complicates understanding for no nothing.
Given the usual command no one, and sure not me, would off spend a single second on it. And what's worth: I now look like an idiot to the ones i asked.

Not everyhing you can do should be done. Keep It Simple. That's my whole point.
(wait a second? init it the arch folks who repeat that like a mantra? well ... looks like it's just blah. ).

now if stick-in-the-ass can give me a better solution for this: grep -r -c srcdir * | grep -v '0$\|1$' ; then i said nothing and got a new master.
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby namibed » November 14th, 2018, 2:16 am

Randicus Draco Albus wrote:I saw a rat a few days ago in a school hallway.

Are you a student or a teacher at Hogwarts?
User avatar
namibed
 
Posts: 42
Joined: September 24th, 2018, 6:24 pm

PreviousNext

Return to Nonsense

Who is online

Users browsing this forum: No registered users and 1 guest

x