Logo 
Search:

Unix / Linux / Ubuntu Forum

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

Script

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

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

#!/bin/bash
File = /etc/filename

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

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

Thanks

Share: 

 

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.




Tagged: