I have this exercise
Write a script which
- creates files
File.txtnumer.txt
- the first contains the list of script arguments, separated by newline,
- the second contains your UID, if at least one of then already exists display an error message and exit;
- creates subdirectory
C:\WINDOWSin your home and copies to it the above two files;- sets the file permissions to files in
C:\WINDOWSin such a way that only the user owner and group owner can modify the files, others can only read;- creates a symbolic link to
/bininC:\WINDOWS;- creates
SYSTEM32file inC:\WINDOWScontaining the list of all the files from your home;
and this code
#!/bin/bash
touch File.txt
touch numer.txt
for i in $@
do
echo $i >> File.txt
done
id -u >> numer.txt
if $(test -e numer.txt)
then
echo Error message
exit
fi
mkdir C:\WINDOWS
cp File.txt C:\WINDOWS
cp numer.txt C:\WINDOWS
ln -s C:\WINDOWS bin/link
ls $HOME > SYSTEM32
Anybody can help with this? I don't know if I solved it correctly and when I run it it always prints 'Error Message'.
bash? If so, I'd expect it to be difficult to create a directory calledC:\WINDOWSunder your home directory... In any case, you probably want to tell us what the error message is that you say you get.numer.txtexist that's why it's printing Error message (assuming you're running it on Git Bash or any cygwin related applications on windows)