Linux Input / Output & VIM commands

technonotes-hacker - Sep 9 - - Dev Community

OUTPUT REDIRECTION

Any command in Linux will have 3 data streams ,

  1. STDIN --> 0
  2. STDOUT --> 1
  3. STDERR --> 2

These numbers are called DESCRIPTOR.

>--> Redirection to a file.
>> --> Upend to the last line.
2> --> This will get the error.
2>> --> Upend the error.
&> --> Both output & error will be stored in the file.

PIPE SYMBOL or PIPE REDIRECTION

  • First command output is the input to the second command.

  • cat file1 | less --> Its like Booklet ( so ENTER ENTER --> it will turn like a page , Down arrow and Up arrow )

  • cat file1 | more

PATTERN MATCHING or CLOBBING

  • * ? [] ! {}
  • touch file{a..z}
  • touch file{1..100}
  • touch file{11,12,17}
  • ls -l file[abcd] --> exact match pattern
  • ls -l !(file) --> list files which is not having any name with file. Its just exclude.
  • To remove all files in one command rm -r file*
  • ls -l ??? --> Single character matching
  • ls -l ?file --> Character matching
  • ls -l file?
  • ls -l /var/log/???

VI

  • sudo yum install vim
  • :set number
  • dd --> delete
  • copy & past --> yy & c
  • cut & past --> dd & c
  • 3 & dd --> it will delete 3 lines from the cursor
  • shift + g --> Last line
  • :1 --> it will go to the first line
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player