Insert Filename into Multiple Files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert Filename into Multiple Files
# 8  
Old 04-04-2013
If that's addressed to me, to ignore case:
Code:
sed "s/$string/& $base/gi" $file > temp

If addressed to other script, ahamed101 already responded.

I don't understand what you mean about excluding files. Can you be more specific?
# 9  
Old 04-04-2013
May I know what the $ in test$ achieves?

@Hanson - What I meant was, if a file already consists of the name of the file, then I do not want to replace anything within that file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert FileName to headers

hi there I have a lot of files with same number of rows and columns.$2 and $3 are the same in all files . I run awk script and merge $2,$3,$1 from first file and $1 from another files. I would like to know how to modify awk script to insert filename as header for merged columns ( Expected... (6 Replies)
Discussion started by: ali.seifaddini
6 Replies

2. Shell Programming and Scripting

Join multiple files with filename

Please help, I want to join multiple files based on column 1, and put the missing values as 0. Also the colname in the output should say which file the values came from. FILE1 1 11 2 12 3 13 FILE2 2 22 3 23 4 24 FILE3 1 31 3 33 4 34 FILE1 FILE2 FILE3 1 11 0 31 (1 Reply)
Discussion started by: newbie83
1 Replies

3. Shell Programming and Scripting

Creating Multiple data files with spaces in the filename

Hi, I have a list of filenames in the format with Spaces in the filename. As an example : Sample File 1.txt Sample File 2.txt Sample File 3.txt.....I have about 100 files like this. I am trying to create a block of code or use an available command to a) Create a file b) Put in some... (2 Replies)
Discussion started by: ban3rj33
2 Replies

4. Shell Programming and Scripting

Renaming multiple files at once (discarding suffix of the filename after a character)

Hi, I have a lot of files similar to the below order. I want to rename all the files .discrading the time stamp/numbers after cnf. Existing files id_info_20130405.cnf_20130801 in_info_20130405.cnf_20130891 iz_info_20130405.cnf_20130821 in_info_20130405.cnf_20130818... (2 Replies)
Discussion started by: saravanapandi
2 Replies

5. Shell Programming and Scripting

Insert a header record (tab delimited) in multiple files

Hi Forum. I'm struggling to find a solution for the following issue. I have multiple files a1.txt, a2.txt, a3.txt, etc. and I would like to insert a tab-delimited header record at the beginning of each of the files. This is my code so far but it's not working as expected. for i in... (2 Replies)
Discussion started by: pchang
2 Replies

6. UNIX for Dummies Questions & Answers

Insert a line into multiple files

HI All, I want to know if it is possible to print the same message but into 2 different files in the same command? Something like . .. ... echo "Text" >> file1 && file2 this is because i creating a script which i use a log but i don't want to duplicate lines of command just to... (5 Replies)
Discussion started by: lordseiya
5 Replies

7. Shell Programming and Scripting

Adding filename and line number from multiple files to final file

Hi all, I have 20 files (file001.txt upto file020.txt) and I want to read them from 3rd line upto end of file (line 1002). But in the final file they should appear to start from line 1. I need following kind of output in a single file: Filename Line number 2ndcolumn 4thcolumn I... (14 Replies)
Discussion started by: bioinfo
14 Replies

8. Shell Programming and Scripting

insert filename into each line of multiple files

I need to insert <filename + comma> into each line of multiple files. Any idea how to script that? Regards, Manu (5 Replies)
Discussion started by: linux.yahoo
5 Replies

9. Shell Programming and Scripting

joining multiple files into one while putting the filename in the file

Hello, I know how to join multiple files using the cat function. I want to do something a little more advanced. Basically I want to put the filename in the first column... One thing to note is that the file is tab delimited. e.g. file1.txt joe 1 4 5 6 7 3 manny 2 3 4 5 6 7 ... (4 Replies)
Discussion started by: phil_heath
4 Replies

10. Shell Programming and Scripting

IBM Informix Load and Insert with multiple files

Hi , Can you guys please help as I have list of files xaa, xab, xac.........xza for eg in which to perform load the 1st (xaa) and insert into table, then only proceed for the 2nd , 3rd and so forth. In other words, before 1st one finished, 2nd one shall not load and insert to table, and so... (0 Replies)
Discussion started by: rauphelhunter
0 Replies
Login or Register to Ask a Question