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


    12
    while true; do echo -ne "$(date)\r"; sleep 1; done
    polaco · 2009-11-17 22:45:37 12
  • 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 : http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html 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


    2
    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 7
  • 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


    0
    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


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


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

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

Create an easy to pronounce shortened URL from CLI
Shorter regex.

Use a Gmail virtual disk (GmailFS) on Ubuntu
Packages: gmailfs fuse-utils libfuse2 gvfs-fuse Config files: /etc/gmailfs/gmailfs.conf; ~/.gmailfs.conf (make a copy from the another one) Unmount: $ fusermount -u /mount/path/ /etc/fstab (Optional): none /mount/path/ gmailfs noauto,user[,username=USERNAME,password=PASSWORD,fsname=VOLUME] 0 0 NOTES: - The options between [] are optional since they already setuped on the config files. - The '-p' flag shows a prompt for the password entry. - It's necessary to add the user to the 'fuse' group. You can do that with: $ sudo chgrp fuse /dev/fuse and $ sudo usermod -a -G fuse USER - The volume name is not needed but highly recommended to avoid file corruption. Also choose a non-trivial name. - Google doesn't approve the use of Gmail account other than e-mail purposes. So, I recommend the creation of a new account for this.

Check Ram Speed and Type in Linux
from http://maysayadkaba.blogspot.com/2008/08/linux-check-ram-speed-and-type.html

Release memory used by the Linux kernel on caches
=1 --> to free pagecache =2 --> to free dentries and inodes =3 --> to free pagecache, dentries and inodes

Shrink more than one blank lines to one in VIM.

Check if you work on a virtual/physical machine in Linux
Command used to know if we are working on a virtual or physical machine. This command will use the dmidecode utility to retrieve hardware information of your computer via the BIOS. Run this command as root or with sudo.

need ascii art pictures for you readme text ?
Require boxes and / or cowsay packages. After input boxes -d dog , type your text and then press ctrl + d . Same goes for cowsay .

video thumbnail gallery
thumbnail gallery of video using totem

statistics in one line
In this example, file contains five columns where first column is text. Variance is calculated for columns 2 - 5 by using perl module Statistics::Descriptive. There are many more statistical functions available in the module.

Print one . instead of each line
If you're running a command with a lot of output, this serves as a simple progress indicator. This avoids the need to use `/dev/null` for silencing. It works for any command that outputs lines, updates live (`fflush` avoids buffering), and is simple to understand.


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: