hi,
i have some files in a directory say
abc.txt
def.txt
ghi.txt
i am storing these file names in a temp file.
ls -l | grep "^-" | awk '{print $NF}' > temp_file$$
i want to add a date time stamp at a particular place in the file names.
it can be
1) before the extension
filename_dateTime.extn
( abc_datetime.txt
)
2) after the extension
filename.extn_datetime
( abc.txt_datetime
)
there is a variable which contains the place where the date time stamp needs to be added.
stamp_pos
which can contain two possible values
filename_DT.extn
filename.extn_DT
i want to parse this string "filename_DT.extn" , and depending on the place where the substring "DT" occurs, i need to add the datetime stamp.
initially i thought, i will 1st read each file name from the temp file(containing list of files in the directory) and also parse the variable stamp_pos and accordingly add substring "DT" to the original file names
suppose,
stamp_pos="filename_DT.extn"
then the DT will be added as
abc_DT.txt
def_DT.txt
ghi_DT.txt
in the next step i thought i will parse the each original file name and replace DT with the date time stamp.
do anyone has an idea how to do this?