Академический Документы
Профессиональный Документы
Культура Документы
1. ACCESS PERMISSIONS
Change the permissions for a file, created in a directory
Instructions:
1.The file name and folder name, to be created should be same as mentioned in the problem
statement.
ANSWERS
mkdir PermissionsEx
cd PermissionsEx
touch sample
Welcome to TCS
Note: The file name and folder name, to be created should be same as mentioned in the above
problem statement
After performing the above activities ,click on the SUMMARY or CONTINUE button to know
the completion status
ANSWERS
mkdir TATA_Ltd
cd TATA_Ltd
vi welcome.txt
[press I , type Welcome to TCS, press esc, :wq, enter, press summary]
Create two Directories named as Directory1 and Directory2 in the Home directory ( default
logged in directory )
Create three files named as file1.txt, file2.txt and file3.txt in the Directory1 and perform the
below operations .
Instructions:
2.The file names and folder names, to be created should be same as mentioned in the problem
statement
3.After performing the above operations, click on SUMMARY or CONTINUE button to know
the completion status
ANSWERS
mkdir Directory1
mkdir Directory2
cd Directory1
touch file1.txt
touch file2.txt
touch file3.txt
mv file2.txt newfile.txt
cp file1.txt ~/Directory2
mv file3.txt ~/Directory2
Directory creation
Create two Directories named as Directory1 and Directory2 in the default logged-in directory (
/home/scrapbook/tutorial/ )
Instructions:
1.The folder name, to be created should be same as mentioned in the problem statement.
ANSWERS
mkdir Directory1
mkdir Directory2
Step 2 of 5
Copy files from Directory1 to Directory2
Instructions:
1.The file names, to be created should be same as mentioned in the problem statement.
ANSWERS
cd Directory1
touch file1.txt
touch file2.txt
touch file3.txt
Step 3 of 5
In continuation to previous steps, perform the below activities:
Instructions:
After completion of the above activities, click on CONTINUE or SUMMARY button to proceed
to next step.
ANSWERS
cp file1.txt ~/Directory2
cp file2.txt ~/Directory2
cp file3.txt ~/Directory2
Step 4 of 5
In continuation previous steps, perform the below activities:
Instructions:
After completion of the above activities, click on CONTINUE or SUMMARY button to proceed
to next step.
ANSWERS
rm file1.txt
rm file2.txt
rm file3.txt
Step 5 of 5
In continuation to previous steps, perform the below activities:
Instructions:
After completion of the above activities, click on SUMMARY or CONTINUE button to proceed
to next step.
ANSWERS
cd ..
rm -r Directory1
Write a command/logic, which will read the content from a given input file and display the
number of lines and number of words in the file.
Note that this folder and file already exists and are located in the path mentioned above.
2.You can open the script.sh file using vi editor, Write the logic inside the file to display the
number of lines and number of words in the input file(input.txt), After writing the logic , save the
file and quit from vi editor .
3.To test your command/logic, Run the shell script file(script.sh) at the terminal using the below
command
sh /home/scrapbook/tutorial/script.sh
4.If any issues while running the above command, Modify the script.sh file and repeat the
point#:3
5.Don't use any echo statement in the script.sh file, even in the commented line/code
Example : Contents of sample Input file named as input.txt - starting from following line
Hello all
Welcome to all of you
Expected Output:
27
ctrl+d
$ sh script.sh (enter)
6. LINES WITH GIVEN PATTERN HANDS-ON
ANSWER
StudentName|Class|SchoolName
Output Format:
The sequence of Column in the output is as below, columns separated by "|"(excluding the
double quotes) ,
SchoolName|Class|StudentName
Note that this folder and file already exists and are located in the path mentioned above.
2.You can open the script file (/home/scrapbook/tutorial/script.sh) file using vi editor, Write the
logic inside the file to Display the students from the school named as Sangamithra from the input
file (input.txt) in the desired order mentioned above . After writing the logic in the script file,
save the file and quit from vi editor .
3.To test your command/logic in script.sh, run the script file at the terminal using the below
command,
sh /home/scrapbook/tutorial/script.sh
4.If any issues while running the above command, Modify the script.sh file and repeat the
point#:3
5.Don't use any echo statement in the script.sh file, even in the commented line/code
6.After completion of the above task , Click on SUMMARY or CONTINUE button to proceed
for the next assignment.
Example :
Deepu|First|Meridian
Neethu|Second|Meridian
Sethu|First|DAV
Theekshana|Second|DAV
Teju|First|Sangamithra
Note:
The column values in each of the above records/row represents one student data in the order of
StudentName,Class and SchoolName respectively and each of these values are separated by "|"
(excluding double quotes )
Expected Output:
Sangamithra|First|Teju
Note: The column values in each of the above records/row represents one student data in the
order of SchoolName,Class and StudentName respectively and each of these values are separated
by "|" (excluding double quotes )
ANSWERS
8. AVERAGE OF MARKS
Average of marks
Write the logic / commands, which will read the contents from the given input file and display
the records of students, whose average of 'two subject marks' is more than 90.
The sequence of columns/contents in the input file(Input.txt) as below and the column values are
separated by "#"(excluding the double quotes)
Output format:
The sequence of column in the output is same as input columns sequence but there is an
additional column for average of marks as the last column.
Instructions:
Note that this folder and file already exists and are located in the path mentioned above.
2.You can open the script file (/home/scrapbook/tutorial/script.sh) file using vi editor, Write the
logic / commands to read the data from input file(Input.txt) , calculate the average of two subject
marks and display the student details, whose average of marks is more than 90. After writing the
logic save the file and quit from vi editor.
3.To test your command/logic in script.sh, run the script file at the terminal using the below
command,
sh /home/scrapbook/tutorial/script.sh
4.If any issues while running the above command, Modify the script.sh file and repeat the
point#:3
5.Don't use any echo statement in the script.sh file, even in the commented line/code
6.After completion of the above task, click on SUMMARY or CONTINUE button to proceed for
the next assignment.
Example:
Deepu#First#Meridian#95#90
Neethu#Second#Meridian#80#75
In the above input content, The values in each row represents one student data in the order of
StudentName,Class,SchoolName,Subject1Marks and Subject2Marks respectively and separated
by "#" (excluding double quotes)
Expected Output:
Deepu|First|Meridian|95|90|92.5
In the above output, The values in each row represents one student data in the order of
StudentName,Class,SchoolName,Subject1Marks,Subject2Marks and Average respectively and
these values are separated by "|"(excluding double quotes).
ANSWERS
vi script.sh
(AFTER ENTERING INTO VI EDITOR PRESS i FOR INSERTION OF TEXT INTO
SCRIPT.SH , then type as below)
awk ‘BEGIN{FS=”#”;OFS=”|”}{s=($4+$5)/2if( s > 90 ) print $1,$2,$3,$4,$5,s;}’
$HOME/unix_subjectaverage/Input.txt
(AFTER COMPLETION OF THIS CODE PRESS ESC AND TYPE :wq AND PRESS ENTER,
the type like this in terminal) sh script.sh
9. CONTENT DISPLAY
ANSWERS (Paste this in script.sh)
cat $1
ls $1