Should work even when very large files exist.
Hold 'Ctrl' + 'Alt' key while selecting rectangular text area of the screen with left mouse button. Should work in any terminal screen (xterm, konsole, ...) under X, if not then try with 'Ctrl' + 'Shift' + 'Alt' or two-combination of these.
This command will display the file, but you can change 'cat' to anything else
(type 'n' when prompted to cancel the command or anything else to proceed).
.
Some hints for newbies:
type
unset bar
to make 'bar' function annihilated.
For permanent usage you can put this (bar) function in your .bashrc (for bash) or in .profile (for sh).
With:
. ~/.bashrc
you can get all new inserted functions in .bashrc (so the function 'bar'
or whatever name you choose) immediately available.
Show Sample Output
(here is character '+' repeated 80 times) Sometimes needed to enhance the title of the script. Show Sample Output
Thanks to pooderbill for the idea :-) Show Sample Output
Usage example: display output of a command running in the background at desired time
The example in details: report disk quotas and that backup process will start soon
In my /etc/crontab file I added following four lines for weekly automatic incremental backup:
.
52 13 * * 7 root mount /dev/sda3 /media/da2dc69c-92cc-4249-b2c3-9b00847e7106
.
53 13 * * 7 knoppix5 df -h >~/df.txt
.
54 13 * * 7 knoppix5 env DISPLAY=:0 /usr/bin/gedit ~/df.txt && wmctl -a gedit
.
55 13 * * 7 root /home/knoppix5/rdiff-backup.sh
.
line one: as root mount media for backup on Sunday 13:52
line two: as user knoppix5 write out to text file in home directory the free space of all mounted disks on Sunday 13:53
line three: in front of you open and display a very simple text editor (I prefer gedit) with content of previously reported disk usage at Sunday 13:54
wmctl -a gedit means (from the manual):
-a Switch to the desktop containing the window , raise the window, and give it focus.
line four: as root run incremental backup script rdiff-backup.sh as root on Sunday 13:54
.
my rdiff-backup.sh, with root permissions backups in short time (writes only changes from the last backup) the etire linux system (except excluded - i.e. you don't want backup recursively your backup disk), looks like this (Show sample output):
Show Sample Output
dir1 and all its subdirs and subdirs of subdirs ... but *no files*
will be copied to dir2 (not even symbolic links of files will be made).
To preserve ownerships & permissions:
cp -Rps dir1 dir2
Yes, you can do it with
rsync -a --include '*/' --exclude '*' /path/to/source /path/to/dest
too, but I didn't test if this can handle attributes correctly
(experiment rsync command yourself with --dry-run switch to avoid
harming your file system)
You must be in the parent directory of dir1 while executing
this command (place dir2 where you will), else soft links of
files in dir2 will be made. I couldn't find how to avoid this
"limitation" (yet). Playing with recursive unlink command loop
maybe?
PS. Bash will complain, but the job will be done.
Show Sample Output
hypnotizing pendulum
Very quick! Based only on the content sizes and the character counts of filenames. If both numbers are equal then two (or more) directories seem to be most likely identical.
if in doubt apply:
diff -rq path_to_dir1 path_to_dir2
AWK function taken from here:
http://stackoverflow.com/questions/2912224/find-duplicates-lines-based-on-some-delimited-fileds-on-line
Show Sample Output
Opposite:
Convert an one-liner to script:
foo() { <one-liner> ; }
...
typeset -f foo
...
unset -f foo
Will highlight search term i.e. "foo" across entire man page (scroll up or down to see) /term_to_search_for+Enter That is how to find things ;) /Enter (slash+empty string+Enter) will jump to the next occurence of previous searched item.
Assumed dir A, B, C are subdirs of the current dir Exact syntax of the command is: rsync -v -r --size-only --compare-dest=/path_to_A/A/ /path_to_B/B/ /path_to_C/C/ (do not omit end-slashes, since that would copy only the names and not the contents of subdirs of dir B to dir C) You can replace --size-only with --checksum for more thorough file differences validation Useful switch: -n, --dry-run perform a trial run with no changes made
make a bunch of files with the same permissions, owner, group, and content as a template file (handy if you have much to do w. .php, .html files or alike)
or
od /dev/urandom -w60 -An|sed 's/ ..../ /g'|head -n 30
(this one lacks digits 8 and 9)
rather don't depend on those sleepin'pills http://en.wikipedia.org/wiki/Counting_sheep
Remove empty lines additionally:
tr -s ' \t\n' <1.txt >2.txt
identical with:
tr -s '[:space:]' <1.txt >2.txt
To "clean perfectly" a text or code file, You can combine this command with
another one:
while read l; do echo -e "$l"; done <1.txt >2.txt
(= remove all leading and trailing spaces or tabs from all lines of a text file)
Any changes to BASH shell made in .bashrc will be active in the current terminal window from the moment you execute this command, ie. aliases, prompt settings etc. No need to restart terminal. (In BASH 'source' simile to 'eval' lets you generally execute any bunch of commands stacked in a text file).
or
tree -ifsF --noreport .|sort -n -k2|grep -v '/$'
(rows presenting directory names become hidden)
The listing will be nice separated with dashes in chunks of identical files. Output format: Size Inode Mode Count_of_identical_files UID GID Date Time Path/Filename Show Sample Output
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: