Useful Commands UNIX SHELL Script part1

List of Useful Commands for UNIX SHELL Scripting

                      Part2                                                            Part3

We all are well aware of Unix Commands but still would like to walk you through some of the commands that we generally come across in our day to day task. Focus would be on the associates who are not very familiar with UNIX. Though simple but still would like to put some light with few commands that comes handy while scripting in UNIX which in turn is invoked by a concurrent program as a host file
Note: Unix is case sensitive.
Here I am categorizing the commands into two sections one set which can be used directly on a UNIX prompt and the one which needs to be executed a Shell Script using a Concurrent program registration.

Section 1

1. Command to Change Directory

Syntax: cd <Path> Or cd $<Custom/Standard Top Name>_TOP (In CAPS)
Path: Here we need to mention the path or directory structure where we want to navigate.
Ex: cd /tmp
Or cd $AR_TOP (Navigates to the AR Module directory)

2. To know the Present Working Directory

Syntax: pwd
Here it would display the path/directory structure where one is currently located.

3. To create a Directory

Syntax: mkdir

4. To list the files in a directory

Syntax: ls –ltr
This is will list the files or folders that exist in the current directory where are executing the command

5. To find a file in a directory where you are currently working

Syntax: find <File Name with Directory Path>

6. Syntax to move a file from one directory to another directory

mv <Source_Directory_Path><file_name> <Destination_Directory_Path><file_name>

7. Remove a file from a where you are currently working

Syntax: rm –f <file anme>

8. Syntax for IF Statement

if [ <expression> ]

9. To fetch the value of a variable we use “$” and to display any value we use “echo”

Example: file_count=1
echo $file_count
This will return 1

10. Finding and removing file/files which is past 7 days old


find <Directory_path> -name "<File_Name>" -mtime +7 -exec rm -f {} \; 

                      Part2                                                            Part3


No comments:

Post a Comment