strace -f -e trace=network -o /tmp/strace.txt -s 10000 <cmd> <args>
Category: linux
Bash history substitution trick
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).<snipped>
!# 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 !!
and !50
(i.e. rerun last command and rerun the 50th history item respectively).
But !#
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.
git submodule usage
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:
cd <submodule-folder>
git pull
cd ..
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.
Check duplicate IP with arping
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 $?
1
bash-4.2 ~$
- exit status of 0 confirms a duplicate ip
git: rebase vs pull/merge
- Instead of a normal pull, try this:
git pull --rebase origin master
- ‘The
--rebase
option tells Git to move all of Mary’s commits to the tip of the master branch after synchronising it with the changes from the central repository.’ - From here: https://www.atlassian.com/git/tutorials/comparing-workflows/centralized-workflow
- This removes the superfluous ‘merge commit’ that comes up normally.
- After fixing a merge conflict:
git add <some-file>
git rebase --continue
- To abort:
git rebase --abort
- Finally:
git push origin master
Bitbucket – checkout a Pull Request
From here: https://gist.github.com/hongymagic/6339056
First add this to .git/config
under the origin
section:
fetch = +refs/pull-requests/*:refs/remotes/origin/pull-requests/*
Then fetch the pull requests:
git fetch origin
Then checkout the one you want:
git checkout pull-requests/1000/from