Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds


  Asked By: Mil    Date: Jun 11    Category: Unix / Linux / Ubuntu    Views: 1724

Hello all,

Just struggling to create these script,i am new in linux and
cant get these right.

1. Write a script that checks if a file is executable. If the file is executable, it should be executed, if not then it should be made executable and executed.

This what i have at moment

File = /etc/filename

if [[ -x "$file" ]]
echo "File '$file' is executable"
chmod +x “$file”

2.A script that allows the extension of a file to be replaced by some other string.
The file whose extension is replaced should be given as an argument.
if no argument is given then the script must generate an error message.
I have an idea the script should be like this but can figure out how to put them together.

$replace =' mv myfile.txt myfile.doc
if $2 is is lost
then error message
else $replace




No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Script Or get search suggestion and latest updates.