Write down UNIX utilities or commands (bash) for the following questions. 1. Lis
ID: 3687177 • Letter: W
Question
Write down UNIX utilities or commands (bash) for the following questions. 1. List all .c file in current directories 2. Count the number of .c files in current directory. 3. Change the access permissions of file foo from r---w---x to rwxr-x--x 4.Execute command "sleep 20" in background 5. Define a environmental variable named "number" with initial value "3320" 6. List all running process and append all output to the end of file out.txt 7. Declare a local variable named "my_date" with initial value of the output of utility date 8. Output the return value (exit code) of last program 9. Send a QUIT signal to the program with pid 123456 10. Use alias to define a command "hello" that output "Hello World!" to standard output screen.Explanation / Answer
1. List all .c file in current directories
ls *.c (or) find . -type f -name *.c
2. Count the number of .c files in current directory.
ls -lR *.c | wc -l
3. Change the access permissions of file foo from r---w---x to rwxr-x--x
chmod 751 foo
4. Executecommand "sleep 20" in background
sleep 20 &
5.Define a environmental variable named "number" with initial value "3320"
export number=3320
6. List all running process and append all output to the end of file out.txt
ps -e > out.txt
7. Declare a local variable named "my_date" with initial value of the output of utility date
my_date=$(date)
echo $my_date
8. Output the return value (exit code) of last program
$ echo $?
9. Send a QUIT signal to the program with pid 123456
# kill -SIGQUIT 123456
10. Use alias to define a command "hello" that output "Hello World!" to standard output screen.
#!/bin/bash
hello="Hello World!"
echo $hello
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.