le coding guide de google pour bash, vraiment pas mal de de points intéressants
y'a des gens qui sont fous quand même :D
un jour si je reviens sur windows, je me servirai bcp de ça je pense
Je mets ça là parce que je m'en rappelle jamais :
This guide explains how to repeat the last command with a substitution under bash shell for command line arguments under Unix like operating systems.
Bash History: Correct / Repeat The Last Command With a Substitution
by Vivek Gite on August 12, 2012 last updated February 23, 2016
in BASH Shell, Linux, UNIX
I often type the wrong command as follows under Linux bash shell:
rsync -av dir1 user@server1.cyberciti.biz:/path/to/dir1
OR
cp -av file1*.txt file2*.txt /path/to/dest
I need to correct those command as follows:
rsync -av dir5 user@server1.cyberciti.biz:/path/to/dir1
cp -av delta1*.txt delta2*.txt /path/to/dest
How do I replace dir1 with dir5 or file with delta and repeat the last command under bash shell?
The bash shell supports both history search and replace operations. The bash (and many other modern) shell provides access to the command history, the list of commands previously typed. The bash shell supports a history expansion feature found in other shell such as csh.
Syntax: Bash history search and replace the command args
The syntax is as follows for quick substitution and repeat the last command, replacing word1 with word2:
^WORD1^WORD2^
OR
!!:s/WORD1/WORD2
OR
!!:gs/WORD1/WORD2
In this example, I’m trying to copy a file called youtube-demo-andriod-app-part1.avi to /backup directory
$ cp youtube-demo-andriod-app-part-102.avi /backup/
To repeat the last command with a substitution:
$ ^102^1002^
OR
$ !!:s/102/1002
Aha c'est moins chiant à faire depuis la dernière mise à jour
Aller, on récupère une feature ultra cool de fedora :
apt-get update; apt-get install -y bash-completion (déjà présent sur ubuntu)
. /etc/bash_completion
complete -F _known_hosts update
Ce truc est présent dans tous les "autres" shells (zsh, fish, whatever) mais c'est un tweak à apporter à bash. C'est dommage que les distributions soient de plus en plus orienté "user lambda" plutôt que "linux user".
Un guide super complet, via je sais plus qui
Mouais, c'est pas un avantage technique que d'utiliser zsh vs bash, tu ajoutes liquidprompt sur ton bashrc et tu as le meme résultat, en mieux.
J'attends toujours les raisons TECHNIQUES qui motivent ce choix :D
on remercie ces braves âmes qui pensent aux fainéants comme nous
ça sert pour les warnings dans les commandes à risque, dans un script :-)
il faudrait que j'arrive à pousser un squelette de script comme ça, une librairie transverse qui contiendrait l'essentiel des bonnes methodes et pratiques ...
seems nice, à tester (via noiz)
[doo:~] $ typeset -u toto
[doo:~] $ toto=TaTa
[doo:~] $ echo $toto
TATA
#awesome
les snippets, c'est la clé du succès du fainéant :D
find . -type d -empty -exec rmdir {} \;
home | blog | popular | study | writing | projects | about | connect
Collection of Less Commonly Used UNIX Commands
September 11th, 2013 | Linux | System Administration | Technology
[ Check out my latest post on the HP Security Blog: “The Secure Web Series, Part 1: Securing The Password Reset Mechanism” ]
unixcommands
Over at Hacker News there are often threads about less-traveled UNIX commands. One particular comment collected a few of the posts, and I decided to parse all of those threads’ commands, plus my own favorite list of obscure entries, and put them in one place.
Somewhat obscure UNIX commands
column: create columns from text input
tr: translate/substitute/delete input
join: like a database join but for text
comm: file comparison like a db join
paste: put lines in a file next to each other
rs: reshape arrays
jot: generate data
expand: replace spaces and/or tabs
time: track time and resourcing
watch: execute something on a schedule in realtime
xargs: execute something on all inputs
iftop: visually show network traffic
jnettop a more detailed iftop
htop: show system stats more powerfully
xxd: manipulate files in hex
mtr: powerful traceroute replacement
mdfind: osx find replacement that uses spotlight
brew: osx package manager
df: disk free
du: disk usage
iotop: i/o stats
dig: dns queries
host: dns queries
man ascii: lookup your ascii
sshfs: mount a directory through ssh
wget: get w’s
dstat: powerful system statistics
tmux: a better screen
jq: command line JSON parsing
pushd: push your pwd to a stack
popd: pop pwd off your stack
lsof: godlike system information [*]
ncat: nmap-based replacement for nc
fuser: kills locking processes
vim: attack yourself
tac: cat in reverse
slurm: network interface stats
rename: change spaces to underscores in names
bmon: a simple bandwidth monitor
open .: in osx, open finder in the current dir
lsmod: show kernel modules
printf: change the format of output
timeout: execute something and kill it soon after
disown: protect a job from disconnect
fc: edit your last command in your editor and execute it
sudo !!: repeat last command with sudo
tee: send output to stdout as well
pgrep: greps through processes
pkill: kills processes based on search
fmt: text formatter
multitail: see logs in separate views
bc: an interactive calculator language
apropos: info on commands
strace: the uber debug tool
man units: interesting
pstree: shows processes in a…well…tree
pv: a progress bar for piped commands
ddate: wtf
zgrep: grep within compressed files
zless: look at compressed files
nping: nmap-based custom packet creation
readlink: read values of links
iostate: look at your disk i/o
atop: another top
split: break a file into pieces
dd: disk writing
ndiff: show differences in nmap scans
ss: socket statistics (show apps using the Internet)