- A palindrome is a word, a phrase, or sequence that reads the same backwards as forwards. Write a shell script that will take one command line argument as string and decide if it is a palindrome. For example:
Ex:
$ ./myprog1.sh βappleβ apple is not a palindrome
Ex:
$ ./myprog1.sh βey edip adanada pide yeβ ey edip adanada pide ye is a palindrome
Your program should work on both lowercase and uppercase letters.
Ex:
$ ./myprog1.sh βMadamβ
Madam is a palindrome
- Write a shell script that takes an optional pathname as parameter. If your program is run with no parameters, it will create a directory named cprogs under current working directory and move all of the files whose name ends with .c to this directory. If your program is run with an argument, it will create a directory names cprogs under given path and move all of the files whose name ends with .c under given path to this directory. For example:
Ex:
$ ./myprog2.sh
A directory named cprogs is created under current working directory.
All the files whose name ends with .c in the current working directory are moved into cprogs directory. Ex:
$ ./myprog2.sh /home/zuhal/Desktop A directory named cprogs is created under /home/zuhal/Desktop. All the files whose name ends with .c in /home/zuhal/Desktop are moved into cprogs directory.
- Write a shell script that will take two integer arguments. The first argument must be greater than the second one. The difference between the two arguments must be an even number. Then your program will draw a hollowed square with the first argument being the side of outer square and the second one being the side of the inner square. For example:
Ex:
$ ./myprogr3.sh 7 5
*******
- *
- *
- *
- *
- *
*******
Ex:
$ ./myprogr3.sh 8 2
********
********
********
*** ***
*** ***
********
********
********
- Write a shell script that takes a wildcard and an optional pathname as an argument. If your program is run only with the wildcard as an argument, then it will search for the words that matches with this wildcard inside all the files whose name ends with .txt under current working directory and substitute them with their uppercase versions. If your program is run with two arguments, one being the wildcard and the other being the pathname, then your program search for the words that matches with this wildcard inside all the files whose name ends with .txt under given pathname and substitute them with their uppercase versions. Note that all of the occurrences of the same word will also be changed. For example:
Ex:
$ ./myprog4.sh βek*β The word βekinβ inside test.txt is substituted with βEKINβ.
The word βekmekβ inside test.txt is substituted with βEKMEKβ. The word βeklemeβ inside deneme.txt is substituted with βEKLEMEβ.
Ex:
$ ./myprog4.sh βan*eβ /home/zuhal/Desktop
The word βanneβ inside /home/zuhal/Desktop/aile.txt is substituted with βANNEβ.
The word βanneβ inside /home/zuhal/Desktop/aile.txt is substituted with βANNEβ. The word βantreβ inside ev.txt is substituted with βANTREβ.
- Write a shell script that takes an optional pathname as an argument and a -R option. If your program is run with no arguments, then it will find all the files whose size is zero under current working directory and ask the user to delete them one by one. If your program is run with a pathname as an argument, then it will find all the files whose size is zero under given pathname and ask the user to delete them one by one. If -R option is given, then your program will work recursively. For example:
Ex:
$ ls -l
-rβwβ- 1 std std 13107 Jun 20 2005 cask-of-amontillado.txt
-rwββ- 1 std std 0 Jun 20 2005 french.txt drwxββ 14 std std 456 May 25 2007 shakespeare -rwββ- 1 std std 0 Jun 20 2005 trees-and-other-poems.txt
$ ls -l shakespeare
-rwββ- 1 std std 456 Jun 20 2005 barleby-scrivener.txt
-rwββ- 1 std std 0 Jun 20 2005 calaveras-county.txt
$ myprogr5.sh -R
Do you want to delete french.txt? (y/n): y
1 file deleted
Do you want to delete trees-and-other-poems.txt? (y/n): n
Do you want to delete calaveras-county.txt? (y/n): y
1 file deleted
Ex:
$ ls -l /home/zuhal/Desktop
-rwxββ 1 std std 0 Jun 20 2005 alice-in-wonderland.txt
-rwββ- 1 std std 496769 Jun 20 2005 hawthorne.txt
-rwββ- 1 std std 172541 Jun 20 2005 looking-glass.txt
drwxββ 14 std std 0 May 25 2007 stories -rβββ 1 std std 0 Jun 20 2005 song-of-hiawatha.txt
$ myprogr5.sh /home/zuhal/Desktop
Do you want to delete alice-in-wonderland.txt? (y/n): y
1 file deleted
Do you want to delete song-of-hiawatha.txt? (y/n): y
1 file deleted
Note that the directories are not deleted. Note also that you can use option and argument at the same time.
- Bonus:You will get 10% extra credit if your program supports a Menu including all questions above. Example:
$ ./myprog.sh Please select an option:
- Check for palindromes
- Move .c files
- Draw hollowed square
- Uppercase conversion
- Delete files
- Exit
These options must be printed inside a loop until βExitβ option is selected. When user enters one choice, you should ask for the arguments if that option requires any.
Reviews
There are no reviews yet.