Ask HN: What are some good examples to demonstrate unix philosophy?
I use gnu parallel a lot and naturally that's my first choice, something like:
$ <urllist ssh user@host 'parallel -j 30 curl "{}" | grep -Po "tel:\d+" | sed "s/tel://" | sort -u'
I use gnu parallel a lot and naturally that's my first choice, something like:
$ <urllist ssh user@host 'parallel -j 30 curl "{}" | grep -Po "tel:\d+" | sed "s/tel://" | sort -u'
# inplace (-i), execute (-e), subtitution of the regular expression 'Pattern' (s/Pattern/), # with the word 'Substitution' (Substitution/), on all matches (g) in file 'filename', you'd do ...
$ sed -i -e 's/Pattern/Substitution/g' <filename>
# Now if you want to do this for all text files under a directory tree ...
$ find -name '.txt' | xargs sed -i -e 's/Pattern/Substitution/g'
# ...while limiting it to just 2 levels of 'depth' ...
$ find -name '.txt' -maxdepth 2 | xargs sed -i -e 's/Pattern/Substitution/g'
# ...and for only those that were modified yesterday ... ... # ...belonging to a certain user .... ...
you get the idea. Other good tools that fall in the similar category are 'sort', 'uniq', 'tr' ...etc. Eg:
$ find /tmp/ -type f -exec stat -c "%s %n" {} \; | sort -n