Professional Documents
Culture Documents
Batch : A3
Roll no : I062
EXPERIMENT 1
Note:- paste the print screen of your output for following commands.
Ans :
1. ls
Ans :
1. Mkdir I062_Madhav_Exp1
2. cd I062_Madhav_Exp1
Ans :
1. vi m1.txt
2. ls
Q.4. Display the contents of the created file.
Ans :
1. cat m1.txt
Q.5. Remove the created directory.
Ans :
1. cd ..
2. rm -rf I062_Madhav_Exp1
3. ls
Q.6. Display the current directory path.
Ans :
1. pwd
Q.7. Write a C program to find factorial of a given number compile and execute
it.
Ans :
1. pico fil1.c
Code :
#include <stdio.h>
if (n < 0)
return -1;
if (n == 0)
return 1;
else
int main()
printf("\n");
int n;
scanf("%d", &n);
return 0;
2. cc fil1.c
3. ./a.out
Q.8. Change the file permission to execute for the created C program file.
Ans :
2. ls -lrt
Q.9. Store the current date into a file.
Ans :
2. cat date.txt
Q.10. Store the count of users into a file.
Ans :
2. cat users.txt
Ans :
2. cat users.txt
3. ls
Q.12. Print the total number of files/directories in current directory on the output
screen.
Ans :
1. ls | wc -l
Q.13. Print the user list with name starting with some character in sorted order.
Ans :
Ans :
1. pico t1.txt
2. pico t2.txt
Ans :
1. head -2 t1.txt
2. head -2 t2.txt
Q.16. Print the last 2 lines of a file.
Ans.
1. tail -2 t1.txt
2. tail -2 t2.txt
Q.18. Count the number of words, characters, lines of a file and store this output
in another file.
Ans :
1. echo "NUMBER OF WORDS : $(wc -w t1.txt | cut -f 1 -d " ")" >> tw.txt
2. echo "NUMBER OF CHARACTERS : $(wc -m t1.txt | cut -f 1 -d " ")" >> tw.txt
3. echo "NUMBER OF LINES : $(wc -l t1.txt | cut -f 1 -d " ")" >> tw.txt
4. cat tw.txt
Ans :
1. ps aux