Linux.com

Home Linux Community Forums New to Linux Getting Started with Linux Shell script to read a .DAT file & rename it

Shell script to read a .DAT file & rename it

Link to this post 11 Mar

I need a batch script which can read a file *.D00000.DAT and find the specific line as below

*-*-* Job: 11676 Name: ABCDEFGH User: mfuser Date: 03/13/13 Time: 10:47:46 *-*-*

and store Job, Name, Date & Time in different variables.

Then do the following:

1. close the file.
2. Rename: keep the original file name & add the "Name" into it. Like below:

ABC2013.C0000.D133136.J11341.D00000.DAT after renaming it should be ABCDEFGH.ABC2013.C0000.D133136.J11341.D00000.DAT

3. Look for other files which has same Job and add the Name in that file name as well. Like below:

ABC2013.C0000.D133136.J11341.D00001.SYSPRINT.DAT will look like ABCDEFGH.ABC2013.C0000.D133136.J11341.D00001.SYSPRINT.DAT

3. Create a folder and name it with Name-Job-Date-Time
3. Move the renamed file into the folder
4. repeat the process for next *.D00000.DAT file

Link to this post 11 Mar

You need? What have you done so far? Looks like homework/assignment...

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board