Assignment 1: Ensure the script checks if a specific file exists in the current directory.
If it exists, print
"File exists", otherwise print "File not found".
Code:
Output:
Assignment 2: Write a script that reads numbers from the user until they enter '0'. The script should
also print whether each number is odd or even.
Code:
Output:
Assignment 3: Create a function that takes a filename as an argument and prints the number of lines
in the file. Call this function from your script with different filenames.
Code:
Output:
Assignment 4: Write a script that creates a directory named TestDir and inside it, creates ten files
named [Link], [Link], ... [Link]. Each file should contain its filename as its content (e.g.,
[Link] contains "[Link]").
Code:
Output:
Assignment 6: Given a sample log file, write a script using grep to extract all lines containing
"ERROR". Use awk to print the date, time, and error message of each extracted line.
Code:
Output:
Assignment 7: Create a script that takes a text file and replaces all occurrences of "old_text" with
"new_text". Use sed to perform this operation and output the result to a new file.
Code:
Output: