Professional Documents
Culture Documents
Linux Practical Urvashisapra 08590202018 Bca 6b
Linux Practical Urvashisapra 08590202018 Bca 6b
This command will create a file with the content entered by user.
ii. cat command to display the file and the content of the file
SYNTAX :- $cat [filename]
1
URVASHI SAPRA 08590202018
2
URVASHI SAPRA 08590202018
OUTPUT:
Command line arguments will display the input with the help of special variable
3. Execute and explain following.
a)
This program shows the sum of 20 numbers that is 0,0+1=1, 1+2=3 and so on.
3
URVASHI SAPRA 08590202018
Sed command is mostly used to replace the text in a file. The below simple sed
command replaces the word “linux” with “unix” in the file.
4
URVASHI SAPRA 08590202018
The substitute flag /g (global replacement) specifies the sed command to replace
all the occurrences of the string in the line.
iii. PARENTHESIZE FIRST CHARACTER OF EACH WORD
SYNTAX:- $ echo "HELLO TO LINUX PRACTICAL" | sed 's/\(\b[A-Z]\)/\(\1\)/g'
This sed example prints the first character of every word in parenthesis
This command will put first letter of each word into parenthesis.
iv. SED COMMAND TO DELETE A LINE
SYNTAX:- $sed 'nth line deletion' [filename]
This command will delete the number of line entered by the user.
5
URVASHI SAPRA 08590202018
This command will exit after a certain number of line which is entered by the user
d)chmod a-x, go+r xstart; ls –l xstart
This command will tranfer the result to result.txt after performing the
mathematical operation in calc.txt
6
URVASHI SAPRA 08590202018
f) Write command to display todays date along with message “Today date
is”
SYNTAX :- echo "Today's date is: $(date +%D)".
We can have a list of user using who command with a pipeline of wc -l command
According to above output as working on a terminal the log in users will be
shown 0 because no new user is using the terminal.
7
URVASHI SAPRA 08590202018
i. Grep command to print only a count of the lines that match a pattern.
SYNTAX :- $grep -c [pattern] [filename]
8
URVASHI SAPRA 08590202018
ii. Grep command to display the matched lines, but do not display the
filenames.
SYNTAX :- $grep -h [pattern] [filename]
9
URVASHI SAPRA 08590202018
10
URVASHI SAPRA 08590202018
11
URVASHI SAPRA 08590202018
v. Grep command to display the matched lines and their line numbers.
SYNTAX :- $grep -n [pattern] [filename]
12
URVASHI SAPRA 08590202018
13
URVASHI SAPRA 08590202018
OUTPUT:
14