$ sudo du /backup/ -h | sort -h
Labels
Data Science
Facts
Humour
Joomla
Linux
Linux Tips
MySQL
PHP
Python
SEO
Technology
Tips
Unicode
Web Server
Windows
Showing posts with label Linux Tips. Show all posts
Showing posts with label Linux Tips. Show all posts
Friday, May 16, 2014
List files in sorted order using 'du'
Listing of all the files (and subdirectories) within a directory along with their sizes in sorted and readable format.
Friday, December 2, 2011
vi Commands
vi is a Visual Editor (hence the name -- vi for VIsual). vi is a widely-used and popular UNIX-based text editor. Like most UNIX system interfaces and other text editors, it lets you control the system by using the keyboard rather than a combination of mouse selections and keystrokes.
Edit a File
Edit a file from command prompt | |
Edit a file from command prompt for reading only | vi -R |
Edit a file from within vi | :e |
Edit a new file from within vi, discard changes to current file | :e! |
Reload current file, discarding changes | :e! |
Go forwards a page | Ctrl+F (or PgDn) |
Go backwards a page | Ctrl+B (or PgUp) |
Move around single lines or characters | Arrow keys |
Save changes | :w |
Save changes and override protected (read-only) files | :w! |
Save changes and exit vi | ZZ |
Quit | :q |
Quit and discard changes | :q! |
Get general help | :help |
Get help on a command (eg. :set) | :help set |
Go to lines, find matching text
Go to line 1234 (do not see typing) | 1234G |
Go to line 1234 (see typing) | :1234 |
Go to start of file | 1G |
Go to end of file | G |
Find (forwards) a line containing "swordfish" | /swordfish |
Find (forwards) a line using a regular expression | /you see .* here |
Repeat last search | n |
Repeat last search in opposite direction | N |
Find (backwards) a line containing "swordfish" | ?swordfish |
Find (backwards) a line using a regular expression | ?you see .* here |
Search case insensitive (Ignore Case) | :set ic |
Search with case sensitivity | :set noic |
Wrap searches back to start of file | :set wrapscan |
Do not wrap searches | :set nowrapscan |
Insert Text
Insert after cursor | i |
Insert before cursor | a |
Insert at beginning of line | I |
Insert at end of line (append) | A |
Open (start) new line below cursor | o |
Open (start) new line above cursor | O |
Advance Deletion
Delete next 5 lines | 5dd |
Delete to end of line | d$ |
Delete to start of line | d0 |
Delete to word "swordfish" | d/swordfish |
Delete to the letter "x" | dfx |
Delete lines 10 to 20 | :10,20d |
Delete current line and another 5 lines | :.,+5d |
Delete all lines | :%d |
Delete current word | dw |
Find line containing pattern, delete it | :/pattern/d |
Find line containing "dog", delete until line containing "cat" | :/dog/,/cat/d |
Delete from current line to line containing "foo" | :.,/foo/d |
Wednesday, February 2, 2011
VI Editor Tips
The VI editor is a screen-based editor used by Linux/Unix users. The VI editor has powerful features to aid programmers. VI has two modes insertion mode and command mode. The editor begins in command mode. Insertion mode begins upon entering an insertion or pressing 'i' in keyboard. [ESC] returns the editor to command mode.
Following tips may be helpful for programmers / content writers.
Execute the command from VI Editor command mode. (press Esc, If Insert mode)
Insert space/character between 2 adjacent characters
Example 1
'LinuxFor' becomes 'Linux For' (Sentence Case)
Example 2
'Kerala government' becomes 'Kerala Governemnt'
Removes all lines starts with a word/patterrn.
Removes all lines begin with 'Ele'
Removes all lines end with 'are'
Removes blank lines
Following tips may be helpful for programmers / content writers.
Execute the command from VI Editor command mode. (press Esc, If Insert mode)
Insert space/character between 2 adjacent characters
Example 1
'LinuxFor' becomes 'Linux For' (Sentence Case)
:%s/\([a-z]\)\([A-Z]\)/\1 \2/g
Example 2
'Kerala government' becomes 'Kerala Governemnt'
:%s/\([a-z]\) \([A-Z]\)/\1 \U\2/g
Removes all lines starts with a word/patterrn.
Removes all lines begin with 'Ele'
:g/^Ele.*$/d
Removes all lines end with 'are'
:g/$*.are/d
Removes blank lines
:g/^$/d
Make First Letter Capital
:%s/^./\U&/
Saturday, December 18, 2010
Compress and split large files under linux
One of the common problems we used to face is transferring large files from Linux through mediums that doesn't support large files, especially when it comes to more than 4 GB files, usually that is a virtual machine hard disk, or backup file.
To compress and split files under linux, this command can be used:
This command will compress and split the "big-file.dvi" to many files with size 650MB for each, giving it the name "small-file.tar.bz.0, small-files.tar.bz.1, etc...."
To join the files together again, this command can be used:
and to extract the output file :
To compress and split files under linux, this command can be used:
$ tar -cvj big-file.dvi | split -b 650M -d - "small-file.tar.bz."
This command will compress and split the "big-file.dvi" to many files with size 650MB for each, giving it the name "small-file.tar.bz.0, small-files.tar.bz.1, etc...."
To join the files together again, this command can be used:
$ cat small-file.tar.bz.* > big-file.tar.bz
and to extract the output file :
$ tar -xvj large-file.tar.bz
Subscribe to:
Posts (Atom)