write a shell script that accepts name from user and
creates a directory by the path name, then creates a text
file in that directory and stores in it, the data accepted
from user till STOP, displays the no. of characters stored
in the file.Program stops if directory name is null
Answer / geichel
#!/bin/bash
echo -n "Enter directory name:"
read x
[[ ${x:='xX'} == 'xX' ]] && echo "error: No filename" &&
exit 0
mkdir --parents "/tmp/$x" 2> /dev/null
echo -n '' > "/tmp/$x/$x.txt"
echo "Enter text. Type 'STOP' on a line by itself to terminate."
while read y
do
[[ "$y" == "STOP" ]] && break;
echo "$y" >> /tmp/"$x"/$x.txt
done
a=$(wc -c "/tmp/$x/$x.txt" | cut -f1 -d' ')
echo
echo "file: /tmp/$x/$x.txt has $a characters"
exit 0;
| Is This Answer Correct ? | 2 Yes | 5 No |
Suppose you execute a command using exec, what will be the status of your current process in the shell?
how to separate the even and odd number generated from one file to two separate file i.e. even numbers in file1.txt and odd numbers in file2.txt
How to include comments in your shell scripts?
What command needs to be used to take the backup?
Write down the syntax for all the loops in shell scripting.
What is the use of break command?
Write a command sequence to find all the files modified in less than 2 days and print the record count of each.
What is the significance of $#?
What is web script?
how is the oppurtunities for unix in the software
c program which accept one argument as a directory name and prints all the file name along with its inode number and total count of the file in directory
Please anyone suggest atleast 2 good training institutes in Hyderabad, INDIA where i can learn unix shell scripting.