I saw the following neat little trick in this link:
# renaming a long file-name using a regex
$ touch config.txt
$ mv config.txt !#:1:s/txt/json
The exact meaning of the
!# is, quoting from the man page:
Event Designators An event designator is a reference to a command line entry in the history list. Unless the reference is absolute, events are relative to the current position in the history list.
! Start a history substitution, except when followed by a blank, newline, carriage return, = or ( (when the extglob shell option is enabled using the shopt builtin).
!# The entire command line typed so far.From ‘man bash’
i.e. most people know that bash can insert things from history using commands like
!50 (i.e. rerun last command and rerun the 50th history item respectively).
!# let’s you take something from the existing line and re-use it.
Here is another example, from here:
curl http://beyondgrep.com/ack-2.14-single-file > ~/bin/ack && chmod 0755 !#:3
In this case,
!#:3 takes the 3rd element from the existing command. Starting from zero, that turns out to be
~/bin/ack in this case.
docker-compose up --abort-on-container-exit
This will stop all containers launched via
docker-compose when one of the containers stops.
nmap -sS -P0 -sV -O 192.168.0.58
- All active IPs in a network
nmap -sP 192.168.0.*
nmap -sP 192.168.0.2-254
- Find unused IPs in a subnet
nmap -T4 -sP 192.168.0.0/24 && egrep "00:00:00:00:00:00" /proc/net/arp
Update: Looks like subtrees are a nicer alternative to submodules. Anyway..
- To update all submodules:
git submodule update --init --recursive
- To fetch the latest code from a submodule:
git commit -am "bumping up submodule version"
Then merge the code. The next time the parent repository is pulled,
updating the submodule will get the latest commit in it.
bash-4.2 ~$ arping 192.168.0.58 -D -c 3 -I ens32
ARPING 192.168.0.58 from 0.0.0.0 ens32
Unicast reply from 192.168.0.58 [18:E7:28:2E:92:9C] 1.747ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)
bash-4.2 ~$ echo $?
- exit status of 0 confirms a duplicate ip
- Instead of a normal pull, try this:
git pull --rebase origin master
git add <some-file>
git rebase --continue
git rebase --abort
git push origin master