In this post, I will share with you ideas on how to create your own command.
One of the best examples is you need to go to a directory and display the contents in the order of edit made. To achieve this you need to issue two commands. Instead of using two commands you can complete this with a single command.
Below are the commands you can use to create your own command in UNIX or LINUX.
I want to go to my home directory and list the components inside of it.
>$ cd (home_dir)
In the above example, I have used two commands. One is ‘cd‘ and another one is ‘lsdm’.
The useful command is ‘alias‘
>$ alias name=’string’
Let me create a new command
>$ alias foo='cd (home_dir); lsdm'
Now new command is created with ‘foo’.
How to check what are the commands defined in a ‘alias-command’. The command is ‘type’
foo is aliased to 'cd (home_dir); lsdm'
How to nullify alias-command. The command is ‘unalias’
>$ unalias foo
Now the ‘alias-command’ foo is no longer present. So the ‘foo’ command is not available now.
How to search for the files and content in the Files
Locate – it will search the pathname of similar to what you entered in any directory.
Find – you can find a particular string in a group of directories.