Write filenames into an array variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Write filenames into an array variable
# 15  
Old 04-24-2012
Sure, you're using a for loop over the files again for no reason. You want to iterate over the array... Re-read the code in post #6 now that you learned how to invoke bash.

https://www.unix.com/302629175-post6.html
# 16  
Old 04-24-2012
It is only for your first 8 files, so perhaps those are the actual file names? Can you post the output of
Code:
ls *.sql

?
# 17  
Old 04-24-2012
NeutronScott,

The outcome for post 6(code by you) is the same as the one i posted. I get the same problem when i run your code as well. The first 8 entries of the array are somehow concatenated to theier previous values.

-A

---------- Post updated at 12:40 PM ---------- Previous update was at 12:34 PM ----------

NeuronScott,

The file names got screwed up somehow. The code is all fine and working perfectly. Thanks all for your help.

-A
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Naming output files based on variable parameters and input filenames

Hello, I have a series of files in sub-directories that I want to loop through, process and name according to the input filename and the various parameters I'm using to process the files. I have a number of each, for example file names like AG005574, AG004788, AG003854 and parameter values like... (2 Replies)
Discussion started by: bdeads
2 Replies

2. Shell Programming and Scripting

Storing filenames in an array in shell script

hi, i am writing a shell script in which i read a line in a variable. FNAME="s1.txt s2.txt s3.txt s4.txt s5.txt" i want to create a array and store single file names in a array.. so the array should contain arr="s1.txt" arr="s2.txt" arr="s3.txt" arr="s4.txt" arr="s5.txt" how to... (3 Replies)
Discussion started by: Little
3 Replies

3. Shell Programming and Scripting

How to get filenames in a directory and write them in to a file?

I need to get the names of files which are starting with a string testfile. Also i want to create a XML file in the same location and write these file names into the XML. Ex: <path> <dir> <file>testfile1</file> </dir> <dir> <file>testfile2</file> </dir>... (4 Replies)
Discussion started by: vel4ever
4 Replies

4. Shell Programming and Scripting

Write array contents to file

Hi, I have a bash script that currently holds some data. I am trying to write all the contents to a file called temp.txt. I am using echo ${array} > temp.txt The problem that I am experiencing is that the elements are being written horizontally in the file. I want them written... (5 Replies)
Discussion started by: Filter500
5 Replies

5. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

6. Shell Programming and Scripting

Storing cutted filenames into variable

Hi, I'd like to write a script which works on various files file1.jpg, file2.jpg ..... These files are splitted and their names are something like file_.XXX. I'd like to merge them and convert them at some moment again in file.XXX also file1_1.jpg file1_2.jpg ... >file1.pdf file2_1.txt... (2 Replies)
Discussion started by: bsco
2 Replies

7. Homework & Coursework Questions

i have no understanding of how to write an array or use one, please help!

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: make 2 files. one to Input 10 numbers and print out the biggest number, and one to Write a script that can check... (1 Reply)
Discussion started by: wendyshephard
1 Replies

8. Shell Programming and Scripting

i have no understanding of how to write an array or use one, please help!

im in a basic unix class and our professor speaks broken engliash so i can never understand what exactly we are doing in class and i have no prior experience with unix. we were given an assignment to make 2 files. one to Input 10 numbers and print out the biggest number, and one to Write a script... (1 Reply)
Discussion started by: wendyshephard
1 Replies

9. Shell Programming and Scripting

Push records to array during implicit loop and write to file

NEWBIE ALERT! Hi, I'm 1 month into learning Perl and done reading "Minimal Perl" by Tim Maher (which I enjoyed enoumously). I'm not a programmer by profession but want to use Perl to automate various tasks at my job. I have a problem (obviously) and are looking for your much appreciated help.... (0 Replies)
Discussion started by: jospan
0 Replies
Login or Register to Ask a Question