Unix Exercise

Reviews
Shared by: Bhanu Chowdary
Stats
views:
394
rating:
not rated
reviews:
0
posted:
11/20/2007
language:
English
pages:
0
IRM UNIX Exercise UNIX Exercise Create a directory with your name under the default home directory for the user “trainee” Create a file “samplefile” in your home directory. Give the file above appropriate permissions if necessary. What do you think appropriate permissions should be? Turn the sticky bit on for the directory you have created Write a script which prompts for your name and then prints on stdout Hello “yourname” Today is “today’s date and time” Write a script to print the names of all the files in the current directory using for loop Create a file “-myfile” in your directory. Remove the above file Write 100 lines in a file each containing text “Unix is a wonderful world” Hint : Use a loop construct Write a shell script which will take 3 command line arguments and perform arithmetic The 3 args in the order are number number operation number is a normal integer operation could be sum, difference or product Hint (Use functions, $#, case, expr etc) Use tail to show the contents of dynamically growing file. Hint echo a message in a file using infinite loop . Also place a delay so that the file doesn‟t grow very rapidly. Open one more session to run tail. Given a file named “/data/training/sam/inputfile”, do the following in separate scripts a. Print the count of all the blank lines b. Print all the lines having the string “new” in them c. Print all the lines having the last field greater than 20000 << The table at the end of this case study should help you >> TATA Consultancy Services Page 1 of 2 IRM UNIX Exercise Copy all the files and subdirectories under /data/training/sam to /data/training/yourgroupdirectory/. Hint: Use tar cvf to create the tar first from /data/training/sam and then untar the created tar under /data/training/yourgroupdirectory using tar xvf Use the find command in /data/training/sam (separate scripts) a. To print all the files having 0 bytes b. To print all the directories c. To print all the files having only read permissions for u,g and o. Use grep or related filter to print lines containing either Arizona or California (case insensitive search) in the file /data/training/sam/inputfile. Read the file /data/training/sam/inputfile line by line and print each line followed by a line saying “This was line n “ n=1,2,3.. In the file ( containing 50 lines “Unix is a wonder….”, replace all the occurrences of wonderful with gruesome ) Also add “This” at the start of each and every line Write a shell script which will write a warning to a file if any of the local filesystems exceeds a certain limit (70 %). The script would write the date and time as well as the name of the filesystem along with the current capacity in percentage. Make entries into the Cron table to run a script every 15 mins. The script should write „Hello World‟ into a file. Write a shell function to demonstrate use of local variables within that function. Declare a variable outside the function and another within the function both with the same name. Use sed to replace all the occurrences of new with old in the file given below. These are the contents of /data/training/sam/inputfile FNAME LNAME STATE AGE AMOUNT mark horton california 23 40000 rafael perez new mexico 21 25000 melody moses alabama 22 10000 joe buselmeir new york 31 50000 tim noble arizona 41 12000 TATA Consultancy Services Page 2 of 2

Shared by: Bhanu Chowdary
Other docs by Bhanu Chowdary
Unix Exercise
Views: 500  |  Downloads: 44
OCA
Views: 575  |  Downloads: 103
UNIX_shell_script_standards_for_PowerCenter_7
Views: 1549  |  Downloads: 129
Related docs
Unix Exercise
Views: 500  |  Downloads: 44
UNIX
Views: 324  |  Downloads: 51
Unix Tutorial
Views: 656  |  Downloads: 87
Introduction to Unix
Views: 8  |  Downloads: 1
Unix_lab exercise
Views: 221  |  Downloads: 14
unix lab2 exercise
Views: 169  |  Downloads: 16
A Basic UNIX Tutorial
Views: 211  |  Downloads: 61
WORKSHEET 1 CDE UNIX
Views: 5  |  Downloads: 2
unix training courses
Views: 22  |  Downloads: 1
Unix Programming Tools
Views: 89  |  Downloads: 19
UNIX Tutorial
Views: 254  |  Downloads: 84