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 14th, 2018, 4:19 am

Teacher in a technical college in the subtropics. I can live with the occasion rat, but not with those damn cockroaches. They are big and a few can even fly!
In a few months I go back to a temperate climate to work at a university.. There should be fewer roaches and hopefully no rats (but I would not bet on it). I was hoping to stay in the subtropics though. The climate is wonderful.
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 Head_on_a_Stick » November 14th, 2018, 7:11 am

nodir wrote: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.

Perhaps I was mistaken then, thank you for the correction. I will look at it tonight when I boot into Debian again.

But the reason why I used that command was because it prints out a list of the filenames followed by the contents of the files.

Do you have a command that could have achieved the same in fewer keystrokes?

I love code golf :geek:

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

Yeah, that's cute but `grep -R .` is a hell of a lot quicker to type, no? :mrgreen:

nodir wrote:there are no symlinks

My understanding of sysfs is incomplete so I was taking no chances :D

nodir wrote:bashism

Why do you keep saying that?

I run the MirBSD™ Korn Shell as my default shell in Debian, I would never use bash.

http://blogstrapping.com/2013.271.13.19.30
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 Randicus Draco Albus » November 14th, 2018, 11:20 am

Head_on_a_Stick wrote:My understanding of sysfs is incomplete so I was taking no chances :D
That is the beauty of the Linux community. Knowledge of a subject is not required to write guides instructing others about said topic. Everyone is free to contribute! Long live software freedom! Long live Stallman! Long live Linus ... Oops the CoC already got him.
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 cynwulf » November 14th, 2018, 1:59 pm

Head_on_a_Stick wrote:
Code: Select all
empty@buster:/sys/devices/system/cpu/vulnerabilities $ grep -R .

Would not something like
Code: Select all
$ grep . /sys/devices/system/cpu/vulnerabilities/*
cut out most of the crap?

Randicus Draco Albus wrote: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:

GNU grep is not the same as OpenBSD's grep. In OpenBSD, there is no difference between -R and -r (and this behaviour is as per the GNU grep -R behaviour - i.e. following all symbolic links).

Incidentally OpenBSD's grep would also assume standard input in head stick's example above where no pattern is specified.

"ggrep" (GNU grep 3.1) can be installed from ports if needed.
User avatar
cynwulf
 
Posts: 2549
Joined: April 26th, 2011, 2:46 pm

Re: Yet another pointless discussion thread...

Postby nodir » November 14th, 2018, 3:18 pm

Head_on_a_Stick wrote:Perhaps I was mistaken then,

Perhaps?
You really got no clue who i asked about that.

If you really wanna use such *and* want to post it publicly, at least add a comment what it does and mainly how it does it.
http://wiki.bash-hackers.org/scripting/ ... guidelines
Last edited by nodir on November 14th, 2018, 6:02 pm, edited 2 times in total.
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby nodir » November 14th, 2018, 3:28 pm

cynwulf wrote:Would not something like
Code: Select all
$ grep . /sys/devices/system/cpu/vulnerabilities/*
cut out most of the crap?

I would say the whole idea to use grep to ***see the whole content of a file*** is a bit strange.
Sure if you fiddle for a bit with it, leaving away path, you get strange results, unpredictable, etc. Hence i call it clusterfuck.
But then: i am not that sure what "cut out the crap" means (the babble here or b) cut out the one line content of each file in that directory?).

Not too sure, but my stomage tells me that i for one would prefer head/tail in this case, which is commonly known to show content of a file, hence straightforward.
I never had such a case, and probably never will have again.
head -n 1 ./*
or rather full path, as you did. cd somewhere, do something, cd back, seems like a long journey too. And on a donkey !

Not sure if i need to say my concern again, but better safe than sorry: simple and clear.
For the rest of the problem/solution grep thing i don't care much. All i said is it lacks simplicity and clarity.
I am quite sure that i read that about short, but hard to understand solutions in "The C programming language too". Simplicity is to be prefered.
I assumed it was my lack of knowlege of a well hidden feature of grep, but, as i stated in my original comment, the masters of bash were pretty puzzled too, and told me to never use such an unclear and pointless construct in a request again. They didn't say it that friendly though.
So: it wasn't me (and not "us" either).

If others like such: just look at arch scripts. They are full of such (non-standard solutions which puzzle people but add nothing).
I will look into such once i have the standard things mastered. That is: probably never.
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby Head_on_a_Stick » November 14th, 2018, 7:35 pm

cynwulf wrote:
Head_on_a_Stick wrote:
Code: Select all
empty@buster:/sys/devices/system/cpu/vulnerabilities $ grep -R .

Would not something like
Code: Select all
$ grep . /sys/devices/system/cpu/vulnerabilities/*
cut out most of the crap?

Well, both commands produce similar output, so yes, I suppose so.

I think I prefer your version, the list is alphabetised by the shell(?), which is nice.
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 Head_on_a_Stick » November 14th, 2018, 7:37 pm

nodir wrote:
Head_on_a_Stick wrote:Perhaps I was mistaken then,

Perhaps?
You really got no clue who i asked about that.

No, I've been looking at it again and I can now confirm that I don't understand it at all :mrgreen:

I saw the command in a post by @loqs over at the Arch forums and I thought it was a neat way to check, that's all.
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 14th, 2018, 8:51 pm

Well: i only was curious. After i couldn't figure out *how* it does what it does, thought: Let's ask and get a oneline answer and be done with it. Then all hell broke lose (perhaps loose?).
And if you reread my first comment, then that is pretty much all i said.

I am slightly proud that i can easily spot if a solution is given by arch (in a broad sense) though. Didn't see that much of them, but if i do, they are like that. Which, as i already said above, is weird, as they always clame arch would be so KISS like.

Perhaps all this back and forth will be useful for someone searching for some solution for/with grep. I guess the best is to not trust the web, the internet or google when it comes to such questions though. It's full of crap, pitfalls, and what not (i can't decide that in general, but what i see at, say linuxquestions, is horrible). Back in the days unix.com was not bad, but it might have changed. shellcheck.net is always good. checkbashism from the debian repos, no clue if it is reliable, but if going for POSIX, might be worth to look at (for scripts, no clue bout oneliners or cli). Also available from the debian repos: posix manpages.
In general, not regarding that grep thingy, which seems to do it's job in this case. I for one like the output-formatting of the "head" solution ... bling-bling.

The legendary skater Duane Peters has said: style is everything ...
nodir
 
Posts: 307
Joined: June 16th, 2015, 10:10 pm

Re: Yet another pointless discussion thread...

Postby Randicus Draco Albus » November 14th, 2018, 11:45 pm

Code: Select all
$ su
$ No.
$ ?
$ You annoy me. Enter your silly commands on a less intelligent computer.
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

PreviousNext

Return to Nonsense

Who is online

Users browsing this forum: No registered users and 1 guest

x