Commands using write (21)

  • This command creates and burns a gapless audio CD with 99 tracks. Each track is a 30 second sine wave, the first is 1 Hz, the second 2 Hz, and so on, up to 99 Hz. This is useful for testing audio systems (how low can your bass go?) and for creating the constant vibrations needed to make non-Newtonian fluids (like cornstarch and water) crawl around. Note, this temporarily creates 500MB of .cdda files in the current directory. If you don't use the "rm" at the end of the command, you can burn more disks using cdrdao write cdrdao.toc Prerequisites: a blank CD-R in /dev/cdrw, sox (http://sox.sourceforge.net/), and cdrdao (http://cdrdao.sourceforge.net/). I'm also assuming a recent version of bash for the brace expansion (which just looks nicer than using seq(1), but isn't necessary). Show Sample Output


    24
    (echo CD_DA; for f in {01..99}; do echo "$f Hz">&2; sox -nt cdda -r44100 -c2 $f.cdda synth 30 sine $f; echo TRACK AUDIO; echo FILE \"$f.cdda\" 0; done) > cdrdao.toc && cdrdao write cdrdao.toc && rm ??.cdda cdrdao.toc
    hackerb9 · 2009-11-17 06:23:42 15
  • Depending on the TERM, the terminfo version, ncurses version, etc.. you may be using a varied assortment of terminal escape codes. With this command you can easily find out exactly what is going on.. This is terminal escape zen! ( 2>&2 strace -f -F -e write -s 1000 sh -c 'echo -e "initc\nis2\ncnorm\nrmso\nsgr0" | tput -S' 2>&1 ) | grep -o '"\\[^"]*"' --color=always "\33]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\33\\\33[!p\33[?3;4l\33[4l\33>\33[?12l\33[?25h\33[27m\33(B\33[m" Lets say you want to find out what you need to echo in order to get the text to blink.. echo -e "`tput blink`This will blink`tput sgr0` This wont" Now you can use this function instead of calling tput (tput is much smarter for portable code because it works differently depending on the current TERM, and tput -T anyterm works too.) to turn that echo into a much faster executing code. tput queries files, opens files, etc.. but echo is very strait and narrow. So now you can do this: echo -e "\33[5mThis will blink\33(B\33[m This wont" More at http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html Show Sample Output


    3
    termtrace(){( strace -s 1000 -e write tput $@ 2>&2 2>&1 ) | grep -o '"[^"]*"';}
    AskApache · 2010-03-17 08:53:41 8
  • In Mac OS X, pressing Command+H will hide an application. While that application's windows vanish, there is no other visual feedback, meaning there is no immediate distinction between an application running with no windows open and a hidden application. This command turns hidden applications' icons transparent, providing a clear and obvious distinction. Change YES to NO to restore the previous functionality.


    1
    defaults write com.apple.Dock showhidden -bool YES
    Vulpine · 2009-02-15 22:13:35 10
  • Mac OS X 10.5 (Leopard) introduced a new, 3D, reflective Dock. For those of us who prefer the Dock to be a little less distracting, this command is the answer. The Dock will be rendered in the same style as when pinned to the left- or right-hand side of the screen. Replace YES with NO to restore the 3D Dock.


    1
    defaults write com.apple.Dock no-glass -boolean YES; killall Dock
    Vulpine · 2009-02-17 23:01:58 8
  • Hides all Files and Folders on the MacOS Desktop. To show files and folders, type "true" instead of "false". "Finder" at the end is case sensitive, "finder" doesn’t work


    1
    defaults write com.apple.finder CreateDesktop -bool false;killall Finder
    vranx · 2019-10-18 12:13:56 1058
  • Dashboard is OS X utility application. When you hit F12, Dashboard springs forward, dimming the background, some people have claimed memory or performance problems. In my case, I just don't use it, there may be other reasons you?d rather not have Dashboard available. Change YES to NO to restore the previous functionality.


    0
    defaults write com.apple.dashboard mcx-disabled -boolean YES; killall Dock
    starchox · 2009-02-17 23:22:24 8

  • 0
    write user anytext
    mahendra · 2009-02-27 18:58:36 12
  • Swap TRUE with FALSE to turn it off again. Note: Finder must be relaunched afterwards to see the effect. For example like this: killall Finder && open /System/Library/CoreServices/Finder.app


    0
    defaults write com.apple.Finder AppleShowAllFiles TRUE
    Svish · 2009-03-09 13:55:31 8
  • This command will use the short username (ie: bsmith) instead of the full (or long) name (ie: Bob Smith), by default in the network authentication dialog, ie: when connecting to servers. Resulting in one less step/time saved. Simply change the boolean value to "NO" (ie: "... -bool NO") to revert to the system's default behavior.


    0
    defaults write /Library/Preferences/com.apple.NetworkAuthorization UseShortName -bool YES
    offworlder · 2009-12-01 05:39:36 4
  • Enables widgets to be placed onto the desktop. Click and hold the widget and press F12 to drag it onto the desktop. Repeat the process again to drag a widget back onto the dashboard. You may need to log off or restart for it to take effect.


    0
    defaults write com.apple.dashboard devmode YES
    rpavlick · 2010-03-30 22:50:27 4
  • Change the file location in the second half of the string to the exact file location of your chosen picture.


    0
    defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture "/System/Library/CoreServices/Finder.app/Contents/Resources/vortex.png"
    rpavlick · 2010-03-30 22:52:19 5

  • 0
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
    rpavlick · 2010-10-06 13:19:41 4
  • Insert an additional (moveable) spacer on the left side of the Dock in Mac OS X


    0
    defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'; killall Dock
    ratonovitch · 2011-07-26 02:03:29 6
  • Insert an additional (moveable) spacer on the right side of the Dock in Mac OS X


    0
    defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}'; killall Dock
    ratonovitch · 2011-07-26 02:05:17 4
  • In Mac OS X, by default, you have to click the mouse on a Terminal window before you can type in it. You can change this behavior to mimic the X11 behavior of focusing on the window on mouseover.


    0
    defaults write com.apple.terminal FocusFollowsMouse -string YES
    ratonovitch · 2011-07-26 02:15:04 4

  • 0
    defaults write com.apple.finder AppleShowAllFiles TRUE
    JimFriend · 2014-05-17 22:00:23 9
  • Pressing a key will now repeat normally, instead of bringing up the accent/more options menu.


    0
    defaults write -g ApplePressAndHoldEnabled -bool false
    JimFriend · 2014-06-06 17:46:36 9
  • pts/33 is variable you can do before you send message to on which pts the user is following ssh youraccount@192.168.1.168 who


    0
    ssh youraccount@192.168.1.168 write toUsername pts/33
    aysadk · 2017-07-27 10:25:38 21
  • In Mac OS 9, the "New Folder" keyboard shortcut was Command+N, but in Mac OS X this was changed to "New Finder Window" instead, with "New Folder" taking the more awkward shortcut of Command+Shift+N. This command reverses their mappings.


    -1
    defaults write com.apple.finder NSUserKeyEquivalents -dict 'New Finder Window' '@$N' 'New Folder' '@N'; killall Finder
    Vulpine · 2009-02-17 23:20:53 11
  • When you press "cmd+n" in TextMate, you can have "HTML" language as default document format... You can also define other languages too. You need to know the UUID of your language bundle.


    -1
    defaults write com.macromates.textmate OakDefaultLanguage 17994EC8-6B1D-11D9-AC3A-000D93589AF6
    vigo · 2009-10-20 07:10:34 4
  • Starts a bunch of background jobs to write random garbage to everyone else's terminals. The "\n" in IFS should be an actual newline, but I can't put that in the command. Show Sample Output


    -1
    tmpIFS=IFS; IFS='\n'; users=`who | awk '{print $1}'`; for u in users; do; write $u < /dev/urandom &; done; IFS=tmpIFS
    tbodt · 2014-02-12 23:36:40 9

What's this?

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.

Share Your Commands


Check These Out

colored prompt
It colors the machine name and current directory different colors for easy viewing.

identify NEEDED sonames in a path
This works in combination with http://www.commandlinefu.com/commands/view/10496/identify-exported-sonames-in-a-path as it reports the NEEDED entries present in the files within a given path. You can then compare it with the libraries that are exported to make sure that, when cross-building a firmware image, you're not bringing in dependencies from the build host. The short version of it as can be seen in the same output is $ scanelf -RBnq -F "+n#f" $1 | tr ',' '\n' | sort -u

Clear your history saved into .bash_history file!
clears the history

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

shell function to underline a given string.
underline() will print $1, followed by a series of '=' characters the width of $1. An optional second argument can be used to replace '=' with a given character. This function is useful for breaking lots of data emitted in a for loop into sections which are easier to parse visually. Let's say that 'xxxx' is a very common pattern occurring in a group of CSV files. You could run $ grep xxxx *.csv This would print the name of each csv file before each matching line, but the output would be hard to parse visually. $ for i in *.csv; do printf "\n"; underline $i; grep "xxxx" $i; done Will break the output into sections separated by the name of the file, underlined.

Display error pages in report format
This command will return a full list of Error 404 pages in the given access log. The following variables have been given to awk Hostname ($2), ERROR Code ($9), Missing Item ($7), Referrer ($11) You can then send this into a file (>> /path/to/file), which you can open with OpenOffice as a CSV

Create a false directory structure for testing your commands
This will make a false directory with the same file names as whatever directory you choose. This is wise to use when testing scripts that alter contents, filenames, or move files. I wrote this after an OOPS I made when renaming a directory of JPGs, PNGs, PSDs that were mixed. I recommend this as I lost over 2000 vacation pictures and some graphics I designed for software and web sites. :( NOTE: This only creates name copies, that data itself is not copied.

how to export a table in .csv file
Exports the result of query in a csv file

Destroy all disks on system simultaneously
This command will use the fdisk utility to find all block devices on your system, and overwrite them with data from the /dev/urandom non-blocking random number generator. CAUTION: This will irrevocably erase EVERY SINGLE physical block storage device visible to the fdisk utility, including plugged USB devices, RAID sets, LVM, etc.

grep lines containing two consecutive hyphens


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: