Check These Out
This can be useful for transforming command-line args into input for xargs (one per line). This can also be done with ls if the args are filenames, but that's getting awfully close to Useless Use of Cat territory (http://partmaps.org/era/unix/award.html).
Only filters the statement related to a specific table ('departments', in the example), from the output of mysqldump
Installs pip packages defining a proxy
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token.
This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use:
`awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'`
You must adapt the command line to include:
* $MFA_IDis ARN of the virtual MFA or serial number of the physical one
* TTL for the credentials
Returns your external IP address to the command line using only wget
This is an extract from a larger script which makes up slideshow videos from images. $seconds is the number of seconds the video will last, and $num is a loop counter which numbers the videos for concat into a longer video later, so they will be in order. The dev/null bit on the end cuts ffmpeg's verbosity.
When expanding, bash output the command, so don't be affraid if you type the command.
Here is the details:
First examples:
$echo foo bar foobar barfoo
First argument:
$echo !$
echo barfoo
barfoo
(Note that typing echo foo bar foobar barfoo && echo !$, bash substitute !$ with $:1)
Last argument:
$echo foo bar foobar barfoo && echo !^
echo foo bar foobar barfoo && echo barfoo
foo bar foobar barfoo
barfoo
All the arguments:
$echo !*
echo foo bar foobar barfoo
foo bar foobar barfoo
The third argument:
$echo foo bar foobar barfoo && echo !:3
echo foo bar foobar barfoo && echo foobar
foo bar foobar barfoo
foobar
You may want to add {} for large numbers: echo !:{11} for example
Now with path:
$echo /usr/bin/foobar
/usr/bin/foobar
For the head:
$echo !$:h
echo /usr/bin
/usr/bin
And the tail:
$echo !$:t
echo foobar
foobar
You also may want to try !:h and !:t or !!3-4 for the third and the fourth (so !!:* == !!:1-$)