Thanks for the reply. I could populate it by directly assigning the output of the ls -l to a variable but, the output of the ls symbol will be loaded into the 0 th position of the testarray , i.e, unix treats it as an normal variable but not as an array variable.
for the grep statement:
here is the error it is throwing:
Any help is highly appreciated.
-A
Quote:
Originally Posted by Chubler_XL
Try this grep -Ev '^\.$|\.\.$' for your grep statement.
You can also populate the array in one go with:
---------- Post updated at 08:50 AM ---------- Previous update was at 07:05 AM ----------
I tried out a new approach and something is going wrong. I am not sure what or why. Could anyone help me tweek the code and make it work?
Error that i am encountering:
script.sh: syntax error at line 12: `(' unexpected
The error is occuring when i am trying to assign the value of ls -l to the variable filename.
---------- Post updated at 09:49 AM ---------- Previous update was at 08:50 AM ----------
Hello All,
I came up finally with a way to assign the values of the filename to an array variable but, the problem is all the values are getting assigned to the first position of the array variable. This is because the count/num variable pointing to the location of the array is not incrementing.
Could anyone please help with this?Help is highly appreciated!!
Last edited by Franklin52; 04-24-2012 at 11:05 AM..
Reason: Please use code tags
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)
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)
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)
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)
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)
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)
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)
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)
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)