https://stackoverflow.com/questions/7393906/highlight-text-similar-to-grep-but-dont-filter-out-text#7394821
Trick is to use ^ to every line with a start-of-line. Since that's unprintable it won't get highlighted.
So to list all the files with arista in the name, but highlight the objects:
find . -name "*arista*" | grep -E '^|\.o|.so'
Friday, August 4, 2017
Friday, May 19, 2017
Find .c or .h or .py files
You can use a regular expression with find:
find . -regex '.*cisco.*\.\(c\|h\|py\)'
finds all cisco-related .c .h or .py files.
find . -regex '.*cisco.*\.\(c\|h\|py\)'
finds all cisco-related .c .h or .py files.
Monday, April 24, 2017
Make Firefox show the https:// bit of an Address
go to:
about:config
make
browser.urlbar.trimURLs
false
about:config
make
browser.urlbar.trimURLs
false
Friday, February 24, 2017
How to fix a spelling mistake in lots of files
First, is it all version controlled?
And are any of the files currently in editor buffers? Close if so.
There are two different versions of rename
the perl-rename that I was expecting
$ rename 's/monkey/reproducer/g' *monkey*
and the rename from util-linux 2.28.2 that's actually on my Fedora box
$ rename monkey reproducer *monkey*
need to do this in all affected directories, there's probably something you can do with find if there are lots
and then to change the text in all the files (recursive)
$ grep -rl monkey . | xargs sed -i 's/monkey/reproducer/g'
finally change it in .bash_history too
sed -i 's/monkey/reproducer/g' ~/.bash_history
note that this will corrupt the history of all the commands you just typed.
And are any of the files currently in editor buffers? Close if so.
There are two different versions of rename
the perl-rename that I was expecting
$ rename 's/monkey/reproducer/g' *monkey*
and the rename from util-linux 2.28.2 that's actually on my Fedora box
$ rename monkey reproducer *monkey*
need to do this in all affected directories, there's probably something you can do with find if there are lots
and then to change the text in all the files (recursive)
$ grep -rl monkey . | xargs sed -i 's/monkey/reproducer/g'
finally change it in .bash_history too
sed -i 's/monkey/reproducer/g' ~/.bash_history
note that this will corrupt the history of all the commands you just typed.
Tuesday, February 14, 2017
rsync and explainshell
My current favourite rsync invocation is:
$ DIR=/home/jla/stuff
$ rsync -Phavz --stats remote:$DIR/ $DIR
and my current favourite way of figuring out what the options mean is:
http://explainshell.com/explain?cmd=rsync+-Phavz+--stats
http://explainshell.com/explain?cmd=rsync+-Phavz+--stats+remote%3A%24DIR%2F+%24DIR
Although it doesn't mention the crucial trailing slash on the source directory, which means that you end up copying /home/jla/stuff/file to /home/jla/stuff/file rather than to /home/jla/stuff/stuff/file.
$ DIR=/home/jla/stuff
$ rsync -Phavz --stats remote:$DIR/ $DIR
and my current favourite way of figuring out what the options mean is:
http://explainshell.com/explain?cmd=rsync+-Phavz+--stats
http://explainshell.com/explain?cmd=rsync+-Phavz+--stats+remote%3A%24DIR%2F+%24DIR
Although it doesn't mention the crucial trailing slash on the source directory, which means that you end up copying /home/jla/stuff/file to /home/jla/stuff/file rather than to /home/jla/stuff/stuff/file.
Tuesday, January 31, 2017
passwordless ssh
* passwordless ssh
https://linuxconfig.org/passwordless-ssh
** make a key
ssh-keygen
** copy it to every machine you can log in to
as you
ssh-copy-id jla@furnace
or as root
ssh-copy-id root@manftest59
https://linuxconfig.org/passwordless-ssh
** make a key
ssh-keygen
** copy it to every machine you can log in to
as you
ssh-copy-id jla@furnace
or as root
ssh-copy-id root@manftest59
Emacs code folding
* Emacs code folding
http://stackoverflow.com/questions/1085170/how-to-achieve-code-folding-effects-in-emacs/1211325#1211325
https://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
M-1 C-x $ and magic happens!
As usual, it’s white magic: C-x $ will bring your code back.
http://stackoverflow.com/questions/1085170/how-to-achieve-code-folding-effects-in-emacs/1211325#1211325
https://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/
M-1 C-x $ and magic happens!
As usual, it’s white magic: C-x $ will bring your code back.
* hg merge not graphical avoid meld >>>>>>> <<<<< =====
* hg merge not graphical avoid meld >>>>>>> <<<<< =====
HGMERGE=merge hg rebase --keep --source ptm-eftest-source --dest origin/master
HGMERGE=merge hg rebase --keep --source ptm-eftest-source --dest origin/master
hg bisect
* hg bisect
https://www.mercurial-scm.org/repo/hg/help/bisect
** basic commands
hg bisect --reset
hg bisect --bad
hg bisect --good
** help is surprisingly readable
hg bisect --help
hg bisect --help --verbose
** automatic usage
hg bisect --reset
hg bisect --bad 34
hg bisect --good 12
hg bisect --command "make && make tests"
https://www.mercurial-scm.org/repo/hg/help/bisect
** basic commands
hg bisect --reset
hg bisect --bad
hg bisect --good
** help is surprisingly readable
hg bisect --help
hg bisect --help --verbose
** automatic usage
hg bisect --reset
hg bisect --bad 34
hg bisect --good 12
hg bisect --command "make && make tests"
hg clean
there's no equivalent to git clean, but
hg status -iu # to show
hg status -iun0 | xargs -r0 rm # to destroy
removes all the ignored (i) and unversioned (u) files that may be lying around (including emacs backup files etc, may be better to do make clean)
and then
hg update -C -r xxxxx
restores the state of the parent (note just -C puts you to tip rather than to where you are)
hg status -iu # to show
hg status -iun0 | xargs -r0 rm # to destroy
removes all the ignored (i) and unversioned (u) files that may be lying around (including emacs backup files etc, may be better to do make clean)
and then
hg update -C -r xxxxx
restores the state of the parent (note just -C puts you to tip rather than to where you are)
Mercurial hg diff patch wiggle
remember diff is from 30652 to 30659 to make a patch that will turn 30652 into 30659
hg diff -r 30652 -r 30659 >~/patch
patch -p1 <~/patch
if the patch fails to apply, the bits can be wiggled in like:
wiggle --replace mc/main/ncsi.c mc/main/ncsi.c.rej
wiggle --replace mc/main/pdma.c mc/main/pdma.c.rej
theoretically
wiggle -rp ~/patch
should do the whole thing, but it can't create files.
hg diff -r 30652 -r 30659 >~/patch
patch -p1 <~/patch
if the patch fails to apply, the bits can be wiggled in like:
wiggle --replace mc/main/ncsi.c mc/main/ncsi.c.rej
wiggle --replace mc/main/pdma.c mc/main/pdma.c.rej
theoretically
wiggle -rp ~/patch
should do the whole thing, but it can't create files.
Subscribe to:
Posts (Atom)