It’s so ingrained, I’m more likely than not to just write it out that way even when I know exactly what I’m doing from the onset.
It’s so ingrained, I’m more likely than not to just write it out that way even when I know exactly what I’m doing from the onset.
e.g.
I need to grab some info from textfile.txt to use as arguments to a function.
cat textfile.txt
looks like its comma delimited.
cat textfile.txt | cut -d, -f 2-5
ah, its the third and fourth column i need
cat textfile.txt | cut -d, -f 3-4 | grep '123456'
perfect
cat textfile.txt | cut -d, -f 3-4 | grep 123456 | tr , ' '
myfunc $(cat textfile.txt | cut -d, -f 3-4 | grep 123456 | tr , ' ')
> looks like its comma delimited.
Interesting; why wouldn't you use `head`? Who knows how big textfile.txt is?
I still uselessly use cat though, it's such a nice way to build a pipeline.
I've been typing cat for over 25 years. Old habits die hard.
lot's of times we sort of know what we are working with, but don't remember the particulars especially
Many of my programs and scripts start output with the line: # cmd arg1 arg2 arg3 ...
and simply echo back lines that start with '#'. That way, I have an internal record of the program that was run and the data file that was read (as well as previous parts of the analysis chain).
And, 'R' ignores lines starting with '#', so the record is there, but does not affect later analyses.
< foo.json jq | pbcopy $ cat somefile ...
with $ <somefile ...
For bash, this only works if you have at least one `|`.