What's the one Linux command you wish you knew years ago?
1–10 of 216 posts
Re: What's the one Linux command you wish you knew years ago?
#2Oh, and "sudo !!". Definitely key, along with "& disown".
Re: What's the one Linux command you wish you knew years ago?
#3screen, pdsh,
perl -pi -e 's/find/replace/g' *.txt
redis-cli's new ability to have piped in data be the last argument of a command.
vim -o file1.txt file2.txt file3.txt (opening multiple files with vim)
Using vim instead of less as a pager: cat file.txt | vim -
Re: What's the one Linux command you wish you knew years ago?
#4Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is:
cat `find . --name *.java` | wc -lRe: What's the one Linux command you wish you knew years ago?
#5Re: What's the one Linux command you wish you knew years ago?
#6For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l
find . -name *.java | xargs cat | wc -l
Re: What's the one Linux command you wish you knew years ago?
#7Re: What's the one Linux command you wish you knew years ago?
#8For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l
Never thought to use ``. I always used xargs: find . -name *.java | xargs cat | wc -l
find . -name *.java -print0 | xargs -0 cat | wc -lRe: What's the one Linux command you wish you knew years ago?
#9For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l
Re: What's the one Linux command you wish you knew years ago?
#10For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l
The {} means "replace with filename" and the semicolon (escaped so your shell doesn't eat it). This will run wc -l for every file that matches.
The -regex flag lets you do the same thing as -name with regular expressions.
The problem with this is we run n different wc's, as opposed to just one with all the parameters. We can use xargs to fix this: find . -name .java | xargs wc -l
This even gives you a total!
The really* simple solution (which is probably best) is to just use shell globbing: wc -l *.java
While find and xargs are definitely useful, the easy solution here works better