Showing posts with label Linux commands. Show all posts
Showing posts with label Linux commands. Show all posts

Wednesday, March 30, 2011

LS: unix command for listing files and directories

ls is a command to list files and directories in Unix and unix like systems.

if it is invoked without any arguments then will list files and folders in current working directory in bare format. In this bare format its difficult to distinguish files and folders and other parameters.
FORMAT: ls [Options] [Filename]
Following are the most common options to be used with "ls".
-a :  Include all files even which are starting with "."(Hidden files in Unix ), by default they are ignored.
-l  : Long format, lists permissions in unix format, size, owner , date modified etc.
-F : Appends a character to reveal the type of file e.g. * for executables '/' for directory
-R : list recursively all the directories and files
-d : list directories instead of content
-t : sort by modification time
-h : Print size in human readable format like 1M, 4G ( Use with -l)

Example: 
For listing files and directories with their parameters like size permissions and all.
> ls -l 
For listing in as ls -l along with size in human readable format..
>ls -h -l

Note: ls can also be used in windows environment with cygwin installation.

Friday, July 30, 2010

Replacing ^M character at end of line using VI editor ( ^H, ^G and so on..)

Some time these characters are placed when you convert file from DOS format to Linux format. These characters can be viewed only with Vi editor or either typing "cat -v" command for that file in command prompt. These characters are called control characters.

These characters can be deleted using ":%s/.$//g" command from VI prompt.
To replace character use it like ":%s/.$/replace/g" Press Ctrl Q+M, and this will character will come up. In some other format it can be typed using ctrl V+M.

But before doing all this do ":set ff=dos", to change file format to DOS.

At last a simple trick for Gvim on Windows XP:
:%s/\r/\r/g
This replaces unix carriage return by windows CRLF.

following is the list of Ctrl characters:

Hex Name
0x00 NUL
0x01 SOH, Control-A
0x02 STX, Control-B
0x03 ETX, Control-C
0x04 EOT, Control-D
0x05 ENQ, Control-E
0x06 ACK, Control-F
0x07 BEL, Control-G
0x08 BS, backspace, Control-H
0x09 HT, tab, Control-I
0x0a LF, line feed, newline, Control-J
0x0b VT, Control-K
0x0c FF, form feed, NP, Control-L
0x0d CR, carriage return, Control-M
0x0e SO, Control-N
0x0f SI, Control-O
0x10 DLE, Control-P
0x11 DC1, XON, Control-Q
0x12 DC2, Control-R
0x13 DC3, XOFF, Control-S
0x14 DC4, Control-T
0x15 NAK, Control-U
0x16 SYN, Control-V
0x17 ETB, Control-W
0x18 CAN, Control-X
0x19 EM, Control-Y
0x1a SUB, Control-Z

Monday, November 16, 2009

Finding free space in android mobile from command line

from ur PC's command prompt you can find out the space available in your android mobile. If you have android SDK installed on ur system then you can type following command:
adb shell df
This command will give you total space, available and used space as following:
/dev: 47172K total, 12K used, 47160K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 0K used, 4096K available (block size 4096)
/system: 65536K total, 61216K used, 4320K available (block size 4096)
/data: 65536K total, 32656K used, 32880K available (block size 4096)
/cache: 65536K total, 1156K used, 64380K available (block size 4096)
/sdcard: 522228K total, 1660K used, 520568K available (block size 2048)


If you don't have SDK then directly on ur device terminal you can type "df" and check the space available.
Otherwise there are some tools available as eclipse memory analyzer which will tell you the memory being utilized by programs when they are running, i have'nt used it till now so I don't know much.