script to include filename with variations at the beginning of the file
Hi there,
I have a bunch of files that I want to modify.
As a beginner, but nevertheless enthusiast, in the use of the shell I want to create a script enabling me to modify those files quickly.
I had only some partial success with various peaces of scripts but I would like to create one script that do all the various actions.
So I have many files looking like these:
There already have content in it but I want to add some content to them. I want to include their names with some variations in the beginning of each files, for example for how-to.html, I want those lines to be added at the beginning of the file:
I did a lot of searching and I basically found this script that seemed to have the bases of what I was looking for:
Trying to get it step by step, I am already stuck at what I think could be logically the best choice for the first one:
first remove the .html extension (to put it back again at the end of the whole process)
second put the name of the file added with _mysite, a line break and again the name of the file
For the first part,I thought about using the following command, which I habe been using for a long time in the terminal without any problem
For the second part, I just made a small modification of the model that I found:
But I cannot figure out why this is not worlking:
There is something wrong in the rename commands are they are not executed but I donīt have a clue.
I tried ' instead of " but it doesnīt change the output, I always get:
Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE / at (eval 1) line 1.
I also put the rename commands inside "for file in * do" and "done;" but no change
Last edited by Franklin52; 03-25-2011 at 11:39 AM..
Reason: Please use code tags
Hello everyone,
I need some help renaming files. I have a directory with a bunch of subfolders in it like so with DWI being the working directory and the 3 levels after it being subdirectories
home/user/Documents/DWI/111180-100/3t_2016-01-07_21-42/003_DTI_siemens_TClessdistort/dtifit_FA.nii.gz... (8 Replies)
Hi Guys,
I have serveral directories like this:
(2013) blablabla(blabla) - blabla (blabla)
or
(1997) blablabla(blabla) - blabla (blabla)
and have to rename them to something like that:
blablabla(blabla) - blabla (blabla) (2013)
and
blablabla(blabla) - blabla (blabla) (1997)
Easy... (2 Replies)
Well you lot seriously amaze me.
There was a thread a few hours ago, (on the date stamp shown in this upload), that generated loads of solutions to a fairly simple problem:-
https://www.unix.com/shell-programming-scripting/235829-how-print-particular-character-n-number-times-line.html
As a... (0 Replies)
Hi, how can I get the mv command to include files beginning with . (such as .htaccess)?
Right now when I mv a directory the .htaccess file is missing and I need to do this on a lot of directories, so there's a lot of wordpress permalinks that don't work anymore because the .htaccess file wasn't... (5 Replies)
Hi, I want to insert one file into another like this:
file 1:
1
2
3
<!-- #include file="file2" -->
4
5
<!-- #include file="file3" -->
6
with the complete output going to another file. Have seen some solutions to similar problems using sed, but this problem is different because it is... (5 Replies)
Hi all,
I have a list of xml file. I need to split the files to a different files when see the <ko> tag.
The list of filename are
B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml
B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml
B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml
... (3 Replies)
Im using awk and I want the output filename to contain the first field of the input file.
Ex.
1 dddd wwwww
1 eeeee wwww
1 wwww eerrrr
2 eeee eeeeee
I want the output files to be xxx1 and xxx2
Thank you (4 Replies)
I'm new in this.
In C/C++, you define variables in one header file & then simply include it in any files where those variables are referenced.
I tried to include a header named DefineVars- which initializes all the globals- but when I add the line "DefineGlobals" at the begining of another... (2 Replies)