Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm new to linux shell scripting. I have 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 under 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 . Any inputs on how I can create another file with the same name of a different file?

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

share|improve this question
2  
Please show us how do you pass input files? –  Gnouc Jun 27 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 at 7:46
add comment

1 Answer

up vote 0 down vote accepted

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

file_name=`ls wip_folder`
log_file="${log_file}.log"
share|improve this answer
    
Thanks much everyone :). This piece of code solved my problem. –  Sravani Jun 27 at 9:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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