Friday, January 28, 2022

Unix For VLSI Industry - Part 4a- TASK 1 - SHELL Scripting


SHELL Scripting Task - 1


In the previous articles or say Assignment 1 and Assignment 2, I have captured few of the practice question related to debugging of SHELL Scripting. We know very well how much this is important from Industry point of view. By now you are very much expert in the UNIX Command and specially writing any Kind of Script using the SHELL Scripting. I am now going to give you few small-small TASK which you can do yourself and these can be used directly in Industry with small modification as per the requirement.

This is the based on script or say automation, we normally use during regression-runs. If you don't know what's regressions - basically engineers run a set of code/tool on large set of small designs (known as Test cases) and analysis the result with respect to each test cases. Few test case are designed to be failed and few suppose to a pass (means should give expected result). If after running the code - result is different from the expected one - We consider regression testcase fail. :)
As you can see that it's looks like Interesting first time but it's huge in numbers and that's the reason there is a lot of automation happen around this using different type of scripting language. Today, we will discuss about the same but in SHELL scripting.

Task 1a -: There is a directory named “regression” inside which there are more than a thousand sub-directories. Each sub-directory has two more sub-directories which are “golden_dir” and “current_dir”. Inside these sub-directories, a file with different versions is present. 
  • Write a script to diff files present in “golden_dir” and “current_dir”. If diff is valid then update the “golden_dir” sub-directory with the new version of the file.

Task 1b -: 
  • Step 1: Write a script named “parent.sh” which run another script with “*.sh” extension only. 
  • If the user has a directory including 100 script files with different extensions in it. Write a script “extension_converter.sh” which can convert any extension of file to “*.sh” extension and call this script inside “parent.sh” script.

Task 1c :- 
  • There is a directory containing more than 100 script files written in python, perl, and TCL syntax. 
  • Each python script has first line i.e., /usr/bin/python
  • Each Perl script has first line i.e., /usr/bin/perl
  • Each tcl script has first line i.e., /usr/bin/tclsh
Write a script to dump python scripts to “python” directory, perl scripts to “perl” directory, and TCL scripts to “TCL” directory.


Task 1d :A directory contains thousands of files created in 2020 and 2021. 
  • Write a script to create a log file which contains the list of all files created in June 2020 along with the modified time.


Try these task and I am sure if you have prepared them today - Tomorrow you can use these in Industry with slight modification.
Stay Tune and Happy Learning.

No comments:

Post a Comment