Commands tagged clear (5)

  • The above code is just an example of printing on the same line, hit Ctrl + C to stop When using echo -ne "something\r", echo will: - print "something" - dont print a new line (-n) - interpret \r as carriage return, going back to the start of the line (-e) Remember to print some white spaces after the output if your command will print lines of different sizes, mainly if one line will be smaller than the previous Edit from reading comments: You can achieve the same effect using printf (more standardized than echo): while true; do printf "%-80s\r" "$(date)"; sleep 1; done

    while true; do echo -ne "$(date)\r"; sleep 1; done
    polaco · 2009-11-17 22:45:37 13
  • While going through the source code for the well known ps command, I read about some interesting things.. Namely, that there are a bunch of different fields that ps can try and enumerate for you. These are fields I was not able to find in the man pages, documentation, only in the source. Here is a longer function that goes through each of the formats recognized by the ps on your machine, executes it, and then prompts you whether you would like to add it or not. Adding it simply adds it to an array that is then printed when you ctrl-c or at the end of the function run. This lets you save your favorite ones and then see the command to put in your .bash_profile like mine at : Note that I had to do the exec method below in order to pause with read. t () { local r l a P f=/tmp/ps c='command ps wwo pid:6,user:8,vsize:8,comm:20' IFS=' '; trap 'exec 66 exec 66 $f && command ps L | tr -s ' ' >&$f; while read -u66 l >&/dev/null; do a=${l/% */}; $c,$a k -${a//%/} -A; yn "Add $a" && P[$SECONDS]=$a; done } Show Sample Output

    for p in `ps L|cut -d' ' -f1`;do echo -e "`tput clear;read -p$p -n1 p`";ps wwo pid:6,user:8,comm:10,$p kpid -A;done
    AskApache · 2010-10-12 06:42:10 8
  • awk can clear the screen while displaying output. This is a handy way of seeing how many lines a tail -f has hit or see how many files find has found. On solaris, you may have to use 'nawk' and your machine needs 'tput' Show Sample Output

    cat /dev/urandom|awk 'BEGIN{"tput cuu1" | getline CursorUp; "tput clear" | getline Clear; printf Clear}{num+=1;printf CursorUp; print num}'
    axelabs · 2009-07-13 07:30:51 5
  • Clear the screen and list file

    alias cls='clear;ls'
    opexxx · 2013-03-19 12:18:47 13
  • This will clear Mac OS's DNS cache, which has been a source of issues for me in the past.

    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    abeardevil · 2017-02-24 18:34:49 17

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

Cleanup firefox's database.
Sqlite database keeps collecting cruft as time passes, which can be cleaned by the 'vacuum;' command. This command cleans up the cruft in all sqlite files relating to the user you have logged in as. This command has to be run when firefox is not running, or it will exit displaying the pid of the firefox running.

Search through files, ignoring .svn
By putting the "-not \( -name .svn -prune \)" in the very front of the "find" command, you eliminate the .svn directories in your find command itself. No need to grep them out. You can even create an alias for this command: $ alias svn_find="find . -not \( -name .svn -prune \)" Now you can do things like $ svn_find -mtime -3

list block devices
Shows all block devices in a tree with descruptions of what they are.

Unbelievable Shell Colors, Shading, Backgrounds, Effects for Non-X
I've been using linux for almost a decade and only recently discovered that most terminals like putty, xterm, xfree86, vt100, etc., support hundreds of shades of colors, backgrounds and text/terminal effects. This simply prints out a ton of them, the output is pretty amazing. If you use non-x terminals all the time like I do, it can really be helpful to know how to tweak colors and terminal capabilities. Like: $ echo $'\33[H\33[2J'

Recursively list all of the files in a directory, group them by extension and calculate the average of the file sizes in each group
Here's an annotated version of the command, using full-names instead of aliases. It is exactly equivalent to the short-hand version. # Recursively list all the files in the current directory. Get-ChildItem -Recurse | # Filter out the sub-directories themselves. Where-Object { return -not $_.PsIsContainer; } | # Group the resulting files by their extensions. Group-Object Extension | # Pluck the Name and Count properties of each group and define # a custom expression that calculates the average of the sizes # of the files in that group. # The back-tick is a line-continuation character. Select-Object ` Name, Count, @{ Name = 'Average'; Expression = { # Average the Length (sizes) of the files in the current group. return ($_.Group | Measure-Object -Average Length).Average; } } | # Format the results in a tabular view, automatically adjusted to # widths of the values in the columns. Format-Table -AutoSize ` @{ # Rename the Name property to something more sensible. Name = 'Extension'; Expression = { return $_.Name; } }, Count, @{ # Format the Average property to display KB instead of bytes # and use a formatting string to show it rounded to two decimals. Name = 'Average Size (KB)'; # The "1KB" is a built-in constant which is equal to 1024. Expression = { return $_.Average / 1KB }; FormatString = '{0:N2}' }

share internet connection with only one network interface
the below command create a alias for share your internet connection with another. $ifconfig eth0:1 Its obviously necessary too activate the iptables post-routing and ip forwarding, as root: $modprobe iptable_nat $iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE $echo 1 > /proc/sys/net/ipv4/ip_forward Be sure that the alias is not your active real ip range

Create a new file

Timer with sound alarm
I'd prefer this one, you have to install espeak to get this running

Print Asterisk phone logs
Prints a log of phonecalls placed from/to an asterisk server, formated into an easily readable table. You can use partial number/queue matches, or use .* to match everything.

This command can be used to extract the IP address of the network.
can be used within a script to configure iptables for example: iface=$2 inet_ip=`ifconfig "$iface" | grep inet | cut -d: -f2 | cut -d ' ' -f1` ipt="sudo /sbin/iptables" ......................... ---------------------------------------------------------------------------------------------------------------- $ipt -A INPUT -i $iface ! -f -p tcp -s $UL -d $inet_ip --sport 1023: --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT ---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- $ipt -A OUTPUT -o $iface -p tcp -s $inet_ip -d $UL --sport 3306 --dport 1023: -m state --state ESTABLISHED,RELATED -j ACCEPT -----------------------------------------------------------------------------------------------------------------

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: