Commands by pascalv (9)

  • Directly download all mp3 files of the desired podcast

    curl | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*mp3" | sort -u | xargs wget
    pascalv · 2021-08-09 13:40:26 51

  • 0
    & 'C:\cwRsync_5.5.0_x86_Free\bin\rsync.exe' --force --ignore-errors --no-perms --chmod=ugo=rwX --checksum --delete --backup --backup-dir="_EVAC/$(Get-Date -Format "yyyy-MM-dd-HH-mm-ss")" --whole-file -a -v "//MyServer/MyFolder" "/cygdrive/c/Backup"
    pascalv · 2020-03-06 10:17:42 16
  • Apart from an exact copy of your recent contents, also keep all earlier versions of files and folders that were modified or deleted. Inspired by the excellent EVACopy Show Sample Output

    backup() { source=$1 ; rsync --relative --force --ignore-errors --no-perms --chmod=ugo=rwX --delete --backup --backup-dir=$(date +%Y%m%d-%H%M%S)_Backup --whole-file -a -v $source/ ~/Backup ; } ; backup /source_folder_to_backup
    pascalv · 2018-08-02 21:27:29 0
  • This takes a picture (with the web cam) every 5 minutes, and send the picture to your e-mail. Some systems support mail -a "References: " so that all video surveillance emails are grouped in a single email thread. To keep your inbox clean, it is still possible to filter and move to trash video surveillance emails (and restore these emails only if you really get robbed!) For instance with Gmail, emails sent to can be filtered with "Matches:" Show Sample Output

    while true ; do fswebcam -d /dev/video0 -r 1280x1024 -F 15 - | uuencode $(date +\%Y\%m\%d\%H\%M).jpeg | mail -s "Video surveillance" ; sleep 300 ; done
    pascalv · 2016-08-09 14:22:45 0
  • Access a random news web page on the internet. The Links browser can of course be replaced by Firefox or any modern graphical web browser.

    links $( a=( $( lynx -dump -listonly "" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | grep -v "" | sort | uniq ) ) ; amax=${#a[@]} ; n=$(( `date '+%s'` % $amax )) ; echo ${a[n]} )
    pascalv · 2016-07-26 11:52:12 17
  • (In French) Connection aux hotspots FreeWifi, et maintien de la connection active

    while true ; do wget --quiet --no-check-certificate --post-data 'login=my_account_number&password=my_password&submit=Valider' '' -O '/dev/null' ; sleep 600; done
    pascalv · 2016-07-23 16:34:42 2
  • Sweep and download all mp3 (in French) of "Rendez-vous avec X" (Meet with M. X) of French public radio From 1997 To 2015 Balaye et telecharge les episodes depuis 1997 jusqu'en 2015

    pascalv · 2015-08-13 21:34:50 3
  • Run "ps -x" (process status) in the background every hour (in this example). The outputs of both "nohup" and "ps -x" are sent to the e-mail (instead of nohup.out and stdout and stderr). If you like it, replace "ps -x" by the command of your choice, replace 3600 (1 hour) by the period of your choice. You can run the command in the loop any time by killing the sleep process. For example ps -x 2925 ? S 0:00.00 sh -c unzip >/dev/null 2>&1 11288 ? O 0:00.00 unzip 25428 ? I 0:00.00 sleep 3600 14346 pts/42- I 0:00.01 bash -c while true; do ps -x | mail pascalv; sleep 3600; done 643 pts/66 Ss 0:00.03 -bash 14124 pts/66 O+ 0:00.00 ps -x kill 25428 You have mail in /mail/pascalv Show Sample Output

    nohup bash -c "while true; do ps -x | mail; sleep 3600; done" | mail &
    pascalv · 2013-08-19 17:21:37 5
  • This will send the web page at $u to . To send the web page to oneself, can be replaced by $(whoami) . The "charset" is UTF-8 here, but any alternative charset of your choice would work. `wget -O - -o /dev/null $u` may be considered instead of `curl $u` . On some systems the complete path to sendmail may be necessary, for instance /sys/pkg/libexec/sendmail/sendmail for some NetBSD.

    { u=""; echo "Subject: $u"; echo "Mime-Version: 1.0"; echo -e "Content-Type: text/html; charset=utf-8\n\n"; curl $u ; } | sendmail
    pascalv · 2010-02-24 04:18:30 1

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Convert entire audio library in parallel
Uses parallel processing Reiteration of my earlier command Usage lc Old_Directory New_DIrectory Old_Format New_Format lc ~/Music ~/Music_ogg mp3 ogg

Show what PID is listening on port 80 on Linux

RDP through SSH tunnel
This command will: 1. open an SSH tunnel to 2. go to background 3. wait for 10 seconds for the connection 4. during the 10 seconds wait it will localy run 'rdesktop' to connect to the remote host through the created SSH tunnel. Password-less log in can be achieved (when server allows it) by adding '-p ' to the 'rdesktop' command

Find the package that installed a command

Given process ID print its environment variables
Same as previous but compatible with BSD/IPSO

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Multi-thread any command
For instance: $ find . -type f -name '*.wav' -print0 |xargs -0 -P 3 -n 1 flac -V8 will encode all .wav files into FLAC in parallel. Explanation of xargs flags: -P [max-procs]: Max number of invocations to run at once. Set to 0 to run all at once [potentially dangerous re: excessive RAM usage]. -n [max-args]: Max number of arguments from the list to send to each invocation. -0: Stdin is a null-terminated list. I use xargs to build parallel-processing frameworks into my scripts like the one here:

Access to specific man page section
You can view the man pages from section five by passing the section number as an argument to the man command

Perl Command Line Interpreter
Can also just use the debug mode like this.

Copy ssh keys to user@host to enable password-less ssh logins.
Alternative for machines without ssh-copy-id

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: