exam Flashcards
In bash what is the function of the following commands and symbols:
sed
SED command in UNIX stands for stream editor and it can perform lots of functions on file like searching, find and replace, insertion or deletion. Though most common use of SED command in UNIX is for substitution or for find and replace. By using SED you can edit files even without opening them, which is much quicker way to find and replace something in file, than first opening that file in VI Editor and then changing it.
SED is a powerful text stream editor. Can do insertion, deletion, search and replace(substitution).
SED command in unix supports regular expression which allows it perform complex pattern matching.
In bash what is the function of the following commands and symbols:
»
> > is used to append to a file
In bash what is the function of the following commands and symbols:
|
Pipe is used to combine two or more commands, and in this, the output of one command acts as input to another command, and this command’s output may act as input to the next command and so on. It can also be visualized as a temporary connection between two or more commands/ programs/ processes
grep
The grep command searches for the pattern specified by the Pattern parameter and writes each matching line to standard output. The patterns are limited regular expressions in the style of the ed or egrep command. The grep command uses a compact non-deterministic algorithm.
$2
./script.sh Hello World
$0 = ./script.sh
$1 = Hello
$2 = World
echo
In computing, echo is a command that outputs the strings that are passed to it as arguments. It is a command available in various operating system shells and typically used in shell scripts and batch files to output status text to the screen or a computer file, or as a source part of a pipeline.
#
comment
$@
$@ refers to all of a shell script’s command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them
ls
In computing, ls is a command to list computer files and directories in Unix and Unix-like operating systems.
cat
Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files
cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to catenate files. It has been ported to a number of operating systems.
cd
The cd command, also known as chdir, is a command-line shell command used to change the current working directory in various operating systems. It can be used in shell scripts and batch files
list all text files in a directory
find . -name ‘*.txt’
list the contents of a user’s home directory
ls ~
print the last 10 lines of a file called animals.txt
tail -10 foo.txt
perform a case-sensitive search of a file called products.txt for all lines
starting with the letter P
grep “^p” foo.txt