Search This Blog

Monday, November 15, 2010

How do I use the scp command to securely transfer files between two computers? or transfer files between 2 unix servers

 In Unix, you can use the scp command to copy files and directories securely between remote hosts without starting an FTP session or logging into the remote systems explicitly. The scp command uses SSH to transfer data, so it requires a password or passphrase for authentication. Unlike rcp or FTP, scp encrypts both the file and any passwords exchanged so that anyone snooping on the network can't view them.

NOTE: Be careful when copying between hosts files that have the same names; you may accidently overwrite them.

The syntax for the scp command is:

  scp [options] [[user@]host1:]filename1 ...  [[user@]host2:]filename2

For more information about scp, consult its man page. At the Unix prompt, enter:

  man scp

Sunday, November 14, 2010

How to delete a file in UNIX?

We can delete the files in unix server by using the rm commnad.

Example: rm filename.

Saturday, November 13, 2010

The GREP Command in unix

The "grep" command allows you to search one file or multiple files for lines that contain a pattern.
Exit status is 0 if matches were found, 1 if no matches were found, and 2 if errors occurred.

Syntax for the grep command is:

grep [options] pattern [files]


-w Match whole word.
-b Display the block number at the beginning of each line.
-c Display the number of matched lines.
-h Display the matched lines, but do not display the filenames.
-i Ignore case sensitivity.
-l Display the filenames, but do not display the matched lines.
-n Display the matched lines and their line numbers.
-s Silent mode.
-v Display all lines that do NOT match.


 grep -v in out.txt

It displays the lines from the out.txt, which the "in" text is not presented.

Wednesday, November 10, 2010

How to search a string in a file?

 we have one file at  location ../test_unix/trial.txt.
 The context of the file[trial.txt] is given below.

 welcome to unix tutorial.
 have a nice day

 Now you want to serach  'have' string in the file, then
 type the below command to find it.

 grep have trial.txt

 output: have a nice day.