Pages

OracleEBSpro is purely for knowledge sharing and learning purpose, with the main focus on Oracle E-Business Suite Product and other related Oracle Technologies.

I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog.

I share my Oracle knowledge through this blog. All my posts in this blog are based on my experience, reading oracle websites, books, forums and other blogs. I invite people to read and suggest ways to improve this blog.


Wednesday, February 27, 2013

Unix Commands


I am not a expert in unix and i always maintain a list of simple commands to work in the black screens..here i am posting it for people like for easy reference...

How to convert a file from dos mode to unix??
some time shell script developed in the window environment will create some problems because of carriage returns and other thing..those can be removed using the follwoing command

dos2unix 
dos2unix movepdf

How to search files in unix??

find . -name "rc.conf" -print

This command will search in the current directory and all sub directories for a file named rc.conf.

Note: The -print option will print out the path of any file that is found with that name. In general -print wil print out the path of any file that meets the find criteria

How to search for a string in a selection of files (-exec grep ...).??

find . -exec grep "murthy ganjam" '{}' \; -print

If you want to just find each file then pass it on for processing use the -q grep option.
This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files.

find . -exec grep -q "murthy ganjam" '{}' \; -print
This command is very important for process a series of files that contain a specific string.
You can then process each file appropriately.

How to view Files in UNIX??
use the cat command

cat filename
The more command will pause after displaying a page of text, and you can go on to the next page of text by hitting the space bar.
You can also do a keyword search of the text by typing

/keyword
For example, if you were looking through a file using the more command, and wanted to skip to the word "drosophila" you would type

/drosophila
and the more command would search through the file until it found that word.

LISTING FILES:

ls -a list all files, including the hidden ones
ls -g list which group owns the files
ls -lag list everything
ls *.txt list only files with a .txt on the end
ls data* list only files that start with the word "data"
ls -lrt list of all the files sorted

ls -la |grep '^d' Look only for files that are directories
ls -la |grep -v '^d' Let's only look for files that are not directories

COPY COMMAND:

cp -r * /tmp you would copy everything in the directory and RECURSIVELY (-r)
everything in the subdirectories underneath that directory to the /tmp directory.

cp file1 file2 copy file1 to a file called file2

cp file1 /tmp copy file1 to the /tmp directory

cp file1 ~smith copy file1 to the home directory of "smith"

cp * /tmp copy everything in the directory to the /tmp directory

MOVE COMMAND:

mv file1 file2 rename file1 to the name file2

mv file1 /tmp move file1 to the /tmp directory

mv file1 ~smith move file1 to the home directory of "smith"

mv * /tmp move everything in the directory to the /tmp directory

mv dir2 /tmp move the directory called dir2,and everything in it, to the /tmp directory
There is no rename command in unix use this command to rename... 

Remove Command:

rm * delete everything in a subdirectory

rm *.txt remove only files with a .txt on the end

rm data* remove only files that start with the word "data"

rm -r dir2 removes everything in the subdirectory "dir2"

CD Command:

cd change to your home directory

cd .. move up one level

cd ~applmgr change to the home directory of user "smith"

cd /tmp change to the /tmp subdirectory

No comments:

Post a Comment