Check These Out
If archive has leading directory level same as archive name and you want to strip it, this command is for you.
The above command will send 4GB of data from one host to the next over the network, without consuming any unnecessary disk on either the client nor the host. This is a quick and dirty way to benchmark network speed without wasting any time or disk space.
Of course, change the byte size and count as necessary.
This command also doesn't rely on any extra 3rd party utilities, as dd, ssh, cat, /dev/zero and /dev/null are installed on all major Unix-like operating systems.
In this example, the command will recursively find files (-type f) under /some/path, where the path ends in .mp3, case insensitive (-iregex).
It will then output a single line of output (-print0), with results terminated by a the null character (octal 000). Suitable for piping to xargs -0. This type of output avoids issues with garbage in paths, like unclosed quotes.
The tr command then strips away everything but the null chars, finally piping to wc -c, to get a character count.
I have found this very useful, to verify one is getting the right number of before you actually process the results through xargs or similar. Yes, one can issue the find without the -print0 and use wc -l, however if you want to be 1000% sure your find command is giving you the expected number of results, this is a simple way to check.
The approach can be made in to a function and then included in .bashrc or similar. e.g.
$ count_chars() { tr -d -c "$1" | wc -c; }
In this form it provides a versatile character counter of text streams :)
The Piano Phase piece, by Steve Reich is a minimalist composition which is played on two pianos played at slightly different tempos, a task that's very difficult to accomplish by human players. The auditive effects produced by the cell displacement produce beautiful patterns.
See https://en.wikipedia.org/wiki/Piano_Phase . My rendered version: https://ydor.org/SteveReich/piano_phase.mp3
Requires sox to be installed on the system.
There are multiple videos on youtube showing different approaches and experiences to this interpretation. There is also a synthesized version.
Even if Bash can behave as a powerful pianist, a simple threaded version leaves full room to several time glitches and even negative displacements, the same issues that human pianists experience when playing the piece. The older the computer, the better the chaos added to the result due to the CPU load. Apparently that's the reason Steve Reich composes pieces such as this.
Without further ado, please give a warm welcome to the Bash minimalist player on synthesized two-threaded pianos. Please turn off your cellphones.
I've corrected the function. My octal conversion formula was completely wrong. Thanks to pgas at http://mywiki.wooledge.org/BashFAQ/071 for setting me straight. The new function is from pgas and is very fast.
Quick method of isolating filenames from a full path using expansion.
Much quicker than using "basename"
Replace 'csv_file.csv' with your filename.
* grep -i leaves only mp3 files (case insentitive)
* sort -R randomizes list (may use GNU 'shuf' instead).
* the sed command will add double quotes around each filename (needed if odd characters are present)
Python comments begin with a #. Modify to suit other languages.
Other uses: Instead of m0 use m$ for end of file or d for deleting all comments.
This command is useful if you want to copy the output of a series of commands to a file, for example if you want to pastebin the output from 'uname -a', 'lspci -vvv' and 'lsmod' for video driver trouble-shooting on your favorite Linux forum.
'log' takes all the following arguments as a command to execute, with STDOUT sent to /var/log/user.log. The command is echoed to the log before it is executed.
The advantages of using logger (as opposed to appending output from commands to a file) are 1) commands are always appended to the logs... you don't have to worry about clobbering your log file accidentally by using '>' rather than '>>' 2) logs are automatically cleaned up by logrotate.
The following functions allow you to mark the start and end of a section of /var/log/user.log.
$ startlog() { export LOGMARK=$(date +%Y.%m.%d_%H:%M:%S); echo "$LOGMARK.START" | logger -t $USER; }
then
$ endlog() { echo "$LOGMARK.END" | logger -t $USER; }
printlog will print all lines between $LOGMARK.START and $LOGMARK.END, removing everything that is prepended to each line by logger.
$ printlog() { sudo sed -n -e "/$LOGMARK.START/,/$LOGMARK.END/p" /var/log/user.log| sed "s/.*$USER: //"; }
The following command should dump just about all the information that you could possibly want about your linux configuration into the clipboard.
$ startlog; for cmd in 'uname -a' 'cat /etc/issue' 'dmesg' 'lsusb' 'lspci' 'sudo lshw' 'lsmod'; do log $cmd; done; endlog; printlog | xsel --clipboard
This is ready for a trip to http://pastebin.com/, and you don't have to worry about leaving temporary files lying around cluttering up $HOME.
Caveats: I'm sure that startlog, endlog, and printlog could use some cleanup and error checking... there are unchecked dependencies between printlog and endlog, as well as between endlog and startlog.
It might be useful for 'log' to send stderr to logger as well.