Write a shell script that will take a filepath and a string as command line arguments. The script should find lines which contain the given 'string' in the given file. It should create an output file in "/tmp" directory with the name in the pattern as below. "NN_15Nov2013_12Hrs_32Minutes_20Seconds.txt"

Recommended Answers

All 3 Replies

Are you asking for help or just the answer? If it is the former please explain what you've tried and how you are stuck.

From your post it appears that you are running Linux/Unix, right? You are writing a bash script? If this is so, study the bash man page: man bash - that should provide you enough information to get started. We don't do your homework for you, but will help you sort out your problems once you have made a reasonable attempt to solve the problem and write the code.

FWIW (this is a hint), to write the data to the appropriate file name means you need to use the "date" command to format the date+time properly in order to generate the file name, and you will need to understand how backquoted commands work in bash.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.