Let us suppose that there is a command such as:
cat /boot/config-3.19.0-32-generic | grep CONFIG_ARCH_DEFCONFIG
The output is as such:
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
Now, my question is: Are there any commands which will only print what is inside the inverted commas, i.e., " "
?
And could you please explain the command a little? Thank you! in advance.
cat
in a pipe is almost always a waste of resources (AKA UUOC);grep
can read its input from a file already (i.e.grep CONFIG_ARCH_DEFCONFIG /boot/config-3.19.0-32-generic
does exactly the same thing, but 1. It's shorter 2. It's easier to understand 3. It doesn't fork an additional shell and an additional process). In 99% of the cases, using cat at the start of the pipe without concatenating multiple files it's just harmful. :)cat
, though useless in this case, would make editing the entire line of commands easier in the future in case you want to change / add / remove something later, maybe atr
orcut
, etc, don't have to find & move the filename, make sure the other command supports it, find where to put it, etc. And for a small test file it only adds 0.002s. (I've probably spent more time typing this than I'll ever save in a lifetime of avoiding superfluouscat
's)cat
help here? You can dogrep foo file | tr
or... | cut
just as easily ascat file | tr | grep ...
. Thecat
just adds an extra five characters, an extra pipe and an extra program call and doesn't simplify anything.