This will list all the files that are a gigabyte or larger in the current working directory. Change the G in the regex to be a M and you'll find all files that are a megabyte up to but not including a gigabyte. Show Sample Output
This will remove all blank lines and lines that start with # to use for commented ines (irrespective of where the # starts in the line).
This is much easier to parse and do something else with (eg: automagically create ZFS vols) than anything else I've found. It also helps me keep track of which disks are which, for example, when I want to replace a disk, or image headers in different scenarios. Being able to match a disk to the kernels mapping of said drive the disks serial number is very helpful
ls -l /dev/disk/by-id
Normal `ls` command to list contents of /dev/disk/by-id
grep -v "wwn-"
Perform an inverse search - that is, only output non-matches to the pattern 'wwn-'
egrep "[a-zA-Z]{3}$"
A regex grep, looking for three letters and the end of a line (to filter out fluff)
sed 's/\.\.\/\.\.\///'
Utilize sed (stream editor) to remove all occurrences of "../../"
sed -E 's/.*[0-9]{2}:[0-9]{2}\s//'
Strip out all user and permission fluff. The -E option lets us use extended (modern) regex notation (larger control set)
sed -E 's/->\ //'
Strip out ascii arrows "-> "
sort -k2
Sort the resulting information alphabetically, on column 2 (the disk letters)
awk '{print $2,$1}'
Swap the order of the columns so it's easier to read/utilize output from
sed 's/\s/\t/'
Replace the space between the two columns with a tab character, making the output more friendly
For large ZFS pools, this made creating my vdevs immeasurably easy. By keeping track of which disks were in which slot (spreadsheet) via their serial numbers, I was able to then create my vols simply by copying and pasting the full output of the disk (not the letter) and pasting it into my command. Thereby allowing me to know exactly which disk, in which slot, was going into the vdev. Example command below.
zpool create tank raidz2 -o ashift=12 ata-... ata-... ata-... ata-... ata-... ata-...
Show Sample Output
grep for 2 words existing on the same line
Human readable representation of the headers of an ICAP request, using tcpdump Show Sample Output
Checks if the aspect ratio is approximately 1.6 (16:10) or ~1.77777778 (16:9). Requires mpv_identify from mpv project https://github.com/mpv-player/mpv/blob/master/TOOLS/mpv_identify.sh (this replaces mplayer -identify, or midentify) Show Sample Output
Uses git grep for speed, relies on a valid she-bang, ignores leading whitespace when stripping comments and blank lines Show Sample Output
debian kernel 4.4.6 Show Sample Output
Extracts the binary from the .text section and escapes it. This puts it in a form ready to use in a program. Show Sample Output
Abort/Break with CTRL-C when no output is shown anymore (break while true loop). Show Sample Output
Runs on at least MacOS Sierra (in Bash) Show Sample Output
The given file may contain any kind of characters. This is compatible for most simple mathematical operation. For the first number found, it will be replaced by the result of a factor operation of 1000. To change the filename or multiplactor or number regular expression, change the first fixed values. Show Sample Output
https://www.howtogeek.com/771399/how-to-use-the-find-command-in-linux/
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: