I'm new to linux shell scripting. I have a few input files that I have to parse one by one. So in my "work in progress" WIP folder I have one input file at a time. While one file is undergoing processing, I want a log file to be created in the LOG folder with the same name as that of input file but with the extension ".log".

Is there any advice on how I can create another file with the same name of a different file?

What I actually want to do is this: copy the filename and store it in a variable, then use the variable to create a $variable.log file and write the log to it.

  • 3
    Please show us how do you pass input files? – cuonglm Jun 27 '14 at 7:44
  • I have an ETL tool setup in my linux box which runs as a cronjob. This picks up a file every five mins from WIP folder. In detail --> I have two cronjobs running. First one downloads files in bulk from fileserver to a local folder. From local folder one at a time will be copied to WIP. Only one file can be in WIP at any given time. This 'one' file will be taken as input by ETL tool which runs once every five mins. – Sravani Jun 27 '14 at 7:46

Assuming that there is only ever one file in the directory:

file_name=`ls wip_folder`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.