Command Combinations

Sometimes it is required to use more than one command in a line or simultaneously. For example:-

If you are using find command and result has a large number of files you can use grep command to search your desired file.

Let"s say we want to find .html files on our system. So we use

# find / -name *.html


It may show you hundreds of file flashing past you on your terminal screen. An alternative is


# find / -name *.html | grep bookmark


This command searches through result for text string "bookmark". Only those files with both strings are outpuut to the screen.

Similarly we can have


# who" grep mj
# ps aux " grep mozilla


The first command who, lists all users currently logged on Linux system. when you pipe(") the result to the grep mj command, you"ll find no. of times that user mj is currently logged on the system.

The second command, ps , lists the process currently running on Linux system. Three switches, aux(a dash is not required ps command switches) , leads very long lists of processes run by all users (a), each associated with username(u) , independent of virtual terminal(x). you need grep to search through these processes. This combined command returns all processes with the word mozilla.


Related Posts:-

Comments

0 Responses to "Command Combinations"

Post a Comment

 

Managing Shell And its Secrets

Subscribe To Get Update On Mobile

Subscribe
Get updates of latest post on your mobile free