In a UNIX environment, a tester frequently involves in -
Running scripts as per test case step requirement.File
manipulation (copying/renaming/deleting)
Navigation (change directory/listing
files/dictionary)
File directory creating
Monitoring
remote log in
Using VI/others editors
Search command "grep"
grep
This command is used to search for information in file/files. Suppose that we have a file restless whose contents are
This command is used to search for information in file/files. Suppose that we have a file restless whose contents are
seafood list fish
warm fish
file
enter
same
fish
list three two one
lost
ashley
list same thins again
ok
bye bye
ok tata
Use ‘grep’ commands
Command:
grep fish restless
grep fish restless
Result:
seafood list fish
warm fish
fish
Command:
grep enter restless
Result:
enter
Command:
grep ola restless
grep ola restless
Result: No output was returned because "ola" is not in file.
‘grep’ can be combined with other command as well with the help of pipe. grep can be combined
with sort command to put out in a alphabetical order. Let’s see
Command:
grep fish restless sort
Result:
seafood list fish
seafood list fish
fish
warm fish
Use ‘man grep’ command to learn more about ‘grep’
No comments:
Post a Comment