Ctrl + a - Jump to the start of the line
Ctrl + b - Move back a char
Ctrl + c - Terminate the command
Ctrl + d - Delete from under the cursor
Ctrl + e - Jump to the end of the line
Ctrl + f - Move forward a char
Ctrl + k - Delete to EOL
Ctrl + l - Clear the screen
Ctrl + r - Search the history backwards
Ctrl + R - Search the history backwards with multi occurrence
Ctrl + t - swapping of the last two char
Ctrl + u - Delete backward from cursor
Ctrl + xx - Move between EOL and current cursor position
Ctrl + x @ - Show possible hostname completions
Ctrl + z - Suspend/ Stop the command
Ctrl + / - Undo last command-line edit
Ctrl + P - Previous command line
Ctrl + N - Next command line (useful for "scrolling" with Ctrl+P)
Ctrl + H - Backspace
Search for Tips & Tricks
Wednesday, February 27, 2008
How to iterate through output
# use this below script for iteration thorugh the output
for i in *.tar.gz; do echo working on $i; tar xvzf $i ; done
the above example will extract all tar.gz file in current folder.
for i in *.tar.gz; do echo working on $i; tar xvzf $i ; done
the above example will extract all tar.gz file in current folder.
Thursday, January 24, 2008
How to redirect output to a file and stdout simultaneously
# How to redirect to stdout and a file
grep 2>&1 | tee
e.g.
grep India *.txt 2>&1|tee output.log
grep
e.g.
grep India *.txt 2>&1|tee output.log
Wednesday, January 23, 2008
How to use find command to find and execute
Find can be clubbed with xargs for finding and executing commands.
e.g.
1. Find log fine in /var and delete them
$ find -path /var -name *.log -exec rm {} \;
e.g.
1. Find log fine in /var and delete them
$ find -path /var -name *.log -exec rm {} \;
Tuesday, January 22, 2008
How to mount a cdrom/pendrive on Linux system
For mounting cdrom user the command as su:
mount -t iso9660 -o ro /dev/cdrom /cdrom
For mounting pendrive the command as su:
mount -t vfat /dev/sda1 /mnt/pendrive
mount -t iso9660 -o ro /dev/cdrom /cdrom
For mounting pendrive the command as su:
mount -t vfat /dev/sda1 /mnt/pendrive
How to list file that doesnot contains some string
Llist files that does not contain string 'dat' in file name
$ ls *[!dat]
$ ls *[!dat]
Sunday, January 20, 2008
How to open remove application on local machine
This can be done using xhost utility:
Step 1. On the local host
Type the following at the command line:
$ xhost +
Step 2. Log on to the remote host
$ telnet
Step 3. On the remote host (through the telnet connection)
Instruct the remote host to display windows on the local host by typing:
$ setenv DISPLAY:0.0
->> user zsh ( shell)
at the command line. (Instead of setenv you may have to use export on
certain shells. in bash shell use DISPLAY=:0.0)
Step 4. Now you can run software from the remote host.
E.g.: when you type $ xterm on the remote host, you should see an
xterm window on the local host.
Step 5. After You Finish
You should remove the remote host from your access control list as follows.
On the local host type:
$ xhost -
Step 1. On the local host
Type the following at the command line:
$ xhost +
Step 2. Log on to the remote host
$ telnet
Step 3. On the remote host (through the telnet connection)
Instruct the remote host to display windows on the local host by typing:
$ setenv DISPLAY
->> user zsh ( shell)
at the command line. (Instead of setenv you may have to use export on
certain shells. in bash shell use DISPLAY=
Step 4. Now you can run software from the remote host.
E.g.: when you type $ xterm on the remote host, you should see an
xterm window on the local host.
Step 5. After You Finish
You should remove the remote host from your access control list as follows.
On the local host type:
$ xhost -
How to Extract a single line from a file
$sed -ne 5p help | /bin/bash
The above command will extract 5th Line from the file 'help'
The above command will extract 5th Line from the file 'help'
Friday, January 18, 2008
How to create/Delete a directory tree
>>>>>>>>>>>>>>>>>> Code >>>>>>>>>>>>>
user File::Path;
mkpath('Level1/Level2/Level3'); # Create all directories tree Level1-->Level2-->Level3
rmtree('Level1/Level2/Level3'); # Delete all directory tree
user File::Path;
mkpath('Level1/Level2/Level3'); # Create all directories tree Level1-->Level2-->Level3
rmtree('Level1/Level2/Level3'); # Delete all directory tree
Thursday, January 10, 2008
How to return reference to a File Handle from Subroutine
>>>>>>>>>>>>>>> Code >>>>>>>>>>>
my $FH = returnFileHandle();
print $FH "Hello, World";
sub returnFileHandle {
my $fileName = "file.txt";
open (FILEHANDLE, ">$fileName") or die $!;
return \*FILEHANDLE;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The subroutine returnFileHandle() returns file handle (in overwrite mode) of file "file.txt".
my $FH = returnFileHandle();
print $FH "Hello, World";
sub returnFileHandle {
my $fileName = "file.txt";
open (FILEHANDLE, ">$fileName") or die $!;
return \*FILEHANDLE;
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The subroutine returnFileHandle() returns file handle (in overwrite mode) of file "file.txt".
Thursday, January 3, 2008
How to delete files in Perl ?
>>> Code >>>>>>
@fileList = (”file1.txt”,”file2.pl”,”file3.java”);
unlink @filelist;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The above code will delete files in fileList arry from current directory. If you want to remove files from a specific directory first use “chdir
Subscribe to:
Posts (Atom)