Bash: For Filename do

bash, filenames

Solution

Fairly straightforward:

for a in Sysbackup*.now;
do
  [ -f $a ] && touch $(basename $a .now).bk ;
done

Problem

Hi I'm not used to do things in Bash, so I'm having some problems: My goal is to look for special files in a folder, and if found generate some other files with the same filenames, but different extension. Something like: ``` For Files-that-are-called-"SysBackup*.Now" do NewFileName = ChangeFileExt(FoundFilename),BK GenerateNewfile(NewFileName) done ``` The above is of course dummycode, I won't bother you with the code I have done, as it is not working :-) So the goal should be: If the folder contains Sysbackup123.now and Sysbackup666.now, I will end up with the files Sysbackup123.bk and Sysbackup666.bk Thank you for any help Michael

Original source