- 3,126 hits
Place for playing with commands…
ODOC: bala@bala:~ less
Less is a program similar to more, but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi.
Most options may be changed either on the command line, or from within less by using the – or — command. Options may be given in one of two forms: either a single character preceded by a -, or a name preceeded by –.
FINDING: -a ........ --search-skip-screen Forward search, skips current screen. -g ........ --hilite-search Highlight only last match for searches. -G ........ --HILITE-SEARCH Don't highlight any matches for searches. -h [N] .... --max-back-scroll=[N] Backward scroll limit. -i ........ --ignore-case Ignore case in searches. -I ........ --IGNORE-CASE Ignore case in searches and in search patterns. -j [N] .... --jump-target=[N] Screen position of target lines. -p [pattern] --pattern=[pattern] Start at pattern (from command line). -t [tag] .. --tag=[tag] Find a tag. -T [tagsfile] --tag-file=[tagsfile] Use an alternate tags file. -y [N] .... --max-forw-scroll=[N] Forward scroll limit. Line Editing: These keys can be used to edit text being entered on the "command line" at the bottom of the screen. RightArrow ESC-l Move cursor right one character. LeftArrow ESC-h Move cursor left one character. CNTL-RightArrow ESC-RightArrow ESC-w Move cursor right one word. CNTL-LeftArrow ESC-LeftArrow ESC-b Move cursor left one word. HOME ESC-0 Move cursor to start of line. END ESC-$ Move cursor to end of line. BACKSPACE Delete char to left of cursor. DELETE ESC-x Delete char under cursor. CNTL-BACKSPACE ESC-BACKSPACE Delete word to left of cursor. CNTL-DELETE ESC-DELETE ESC-X Delete word under cursor. CNTL-U ESC (MS-DOS only) Delete entire line. UpArrow ESC-k Retrieve previous command line. DownArrow ESC-j Retrieve next command line. TAB Complete filename & cycle. SHIFT-TAB ESC-TAB Complete filename & reverse cycle. CNTL-L Complete filename, list all.
Ex: $ man pwd | less +/print
Output: View the man page for the pwd command; begin at the first appearance of the word “print“
ODOC: bala@bala:~ lsusb
It is a utility for displaying information about USB buses in the system and the devices connected to them. For specific bus use -s with id no.
Ex: $ lsusb
ODOC: bala@bala:~ locale It shows information about the current locale environment or all locales to standard output.
Ex: $ locale -a
option: -m (for available charmaps)
ODOC: bala@bala:~ Grep command searches the given file for lines containing a match to the given strings or words. By default, grep prints the matching lines. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. -r used for recursive.
Ex: $ grep -r welcome *
/home/user/Desktop/file.txt:Welcome to “ODOC”
/media/Ubuntu/new.py: welcome to python
ODOC: bala@bala:~ Grep command searches the given file for lines containing a match to the given strings or words. By default, grep prints the matching lines. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines.
Ex: $ grep welcome first.txt
Output: Welcome to “ODOC”
It will find the string related to welcome in first.txt and prints the line.
ODOC: bala@bala:~ A pipe is a means by which the output from one process becomes the input to a second. In technical terms, the standard output (stout) of one command is sent to the standard input (stdin) of a second command. If you are not sure of the advantages this creates, then let’s look at a simple example.
Ex: $ echo Hello World! | rev
output: !dlroW olleH
ODOC: bala@bala:~ Commands can be repeated for several time using ‘for’. The structure is for varname in list; do commands…………; done
Ex-$ for file in *.txt do mv-v .old; done