Nice reading in the morning on the way to work, but sadly the .tar.gz for the whole issue 66 is not on phrack's website yet. So use wget to download.
This function does a batch edition of all OOO3 Writer files in current directory. It uses sed to search a FOO pattern into body text of each file, then replace it to foo pattern (only the first match) . I did it because I've some hundreds of OOO3 Writer files where I did need to edit one word in each ones and open up each file in OOO3 gui wasn't an option. Usage: bsro3 FOO foo
I think this is less resource consuming than the previous examples
Here is how to replicate the directory structure in the current directory to a destination directory (given by the variable DESTDIR), without copying the files.
This shell function takes a single argument, which is used as the base name of the .wav, .timing and .session files created. To create a screencast:
screencast test
type and talk ...
then type 'exit' or to exit the screencast.
test.wav will contain the audio from your screencast.
test.session will contain text and control characters needed to paint the screen
test.timing will contain timing information needed to synch individual keystrokes in test.session with the audio.
to play back:
aplay test.wav & scriptreplay test.{timing,session}
NOTE: because the shell function uses the variable "$!", and bash likes to expand '!' during history expansion, you will need to turn off bash's history before you enter the shell function.
This can be achieved using the command
set +H
Change n directories up, without parameters change one up Show Sample Output
Usage: ytmp3 "YTurl" "YTurl2" "YTurl3" "YTurlN" Uses the shift command to let you extract the .mp3 from as many youtube urls as you like (or wherever else youtube-dl is supported) *Requires youtube-dl Orginal chunk of code: youtube-dl -q -t --extract-audio --audio-format mp3 URL taken from here http://www.commandlinefu.com/commands/view/9701/convert-youtube-videos-to-mp3 Show Sample Output
It find out the mic recording level at the moment of run the command and if a noise level is higher it starts to record an mp3 file. The resulting file will have only the sounds not the silences.
This is probably overkill, but I have some issues when the directories have spaces in their names.
The
find . -type d -print0 | while read -d $'\0' dir; do xxx; done
loops over all the subdirectories in this place, ignoring the white spaces (to some extend).
cd "$dir"; echo " process $dir"; cd -;
goes to the directory and back. It also prints some info to check the progress.
find . -maxdepth 1 -name "*.ogg.mp3" -exec rename 's/.ogg.mp3/.mp3/' {} \;
renames the file within the current directory.
The whole should work with directories and file names that include white spaces.
Show Sample Output
Create and access directory (edited)
The previous alternative dont work (the cd command was missing).
Finder compresses to ZIP but always includes extraneous metadata files (__MACOSX and .DS_Store) files and folders that may confuse other programs. One alternative is creating them and then editing the ZIP. This can work standalone or in an automator script accepting multiple selections (files or folders) and creating one zip per argument/selected file without that metada.
cd - would return to the previous directory of your cd command. NB: previous dir is always stored in $OLDPWD variable. Show Sample Output
uses tar to dump files from /orignl/path to /dst/dir. i find tar's out more readable than cp, and it doesn't mess with modified dates.
!$ recalls the last argument of the previous command. This is very useful when you have to operate several operations on the same file for example. Show Sample Output
For use in scripts this command is very usefull
It copies the entire current working directory to the destination directory with compression enabled.
Just a copy of a big dir when you wan't things like ownership and date etc etc to be untouched. Note: Updated with the ideas from "mpb".
fcd : file change directory A bash function that takes a fully qualified file path and cd's into the directory where it lives. Useful on the commadline when you have a file name in a variable and you'd like to cd to the directory to RCS check it in or look at other files associated with it. Will run on any ksh, bash, likely sh, maybe zsh. Show Sample Output
_ expands to the last argument of the last command that was executed
Creates a directory named with the current date, in the format YYYYMMDD. If you give it a directory name as an argument, it will create the new directory inside the specified directory. This is an alternative to command #1993. Show Sample Output
Grabs the cmdline used to execute the process, and the environment that the process is being run under. This is much different than the 'env' command, which only lists the environment for the shell. This is very useful (to me at least) to debug various processes on my server. For example, this lets me see the environment that my apache, mysqld, bind, and other server processes have.
Here's a function I use:
aa_ps_all () { ( cd /proc && command ps -A -opid= | xargs -I'{}' sh -c 'test $PPID -ne {}&&test -r {}/cmdline&&echo -e "\n[{}]"&&tr -s "\000" " "<{}/cmdline&&echo&&tr -s "\000\033" "\nE"<{}/environ|sort&&cat {}/limits' ); }
From my .bash_profile at http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
Clone directory structure without the files
commandlinefu.com 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.
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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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: