ls -l *.log | set -A arr_Filenames $(awk '{print $9}')
That awk statement is out of place -- did you want to estract 9th column from ls output? Why do you use -l option then at all?
Try this:
or, if you really want to filter the output of ls command:
The var=() construct will make 'var' an array. (In Bash, at least)
You can also assign into array in a following way:
Which will read each line of input being piped in into an array (-a switch of built-in read).
I am using MKS Toolkit to execute the shell script.
Error Unknown option "-a"
Error 43: syntax error: got (, expecting Newline
I am trying to list all files from the directory and delete which are two months old. My file has a f1_YYYY-MM-DD.log.
Wanted to delete which are two months old.
OK. From what I understand, MKS toolkit supports different shells. What is the first line of your script? (starting with #!)
Quote:
am trying to list all files from the directory and delete which are two months old
This should work:
will execute 'ls -l <filename>' on all files inside current directory and all subdirectories that were modified more than 60 days ago. Look at 'man find' to check the 'mtime' option.
If you know the name format of your log files, you should specify that also to filter out old files that you might want to keep.
The following will remove all files named f1_YYYY-MM-DD.log inside the current dir (and any level deep), that were modified at least 60 days ago. You should test this without the '-exec rm {} \;' part first, to list the files matched by find; then when you are sure, run the whole thing to delete them.
Given a directory containing say a few thousand files,
please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents.
func(a_directory_name) output -> {“matches”: , ... ]}
e.g. func(“/home/my/files”) where the directory... (7 Replies)
Hi all,
I have a directory with multiple (thousnads) of files, which are named this way
ABCDEF.wo.im-1
OKRAME.ire.roi
IOJEAFO01.irt.gfg
IMNYBL05.REG.gkf
I would like to keep the part of the name (everything before the first dot in the filename).
The desired output:
ABCDEF... (3 Replies)
Hello I'm trying to do an exercise programming in bash where I have to get only the store of files in a directory but NOT all capacity of the directory.
I probe with: du -sh "$directory"*` but I get all the capacity and I probe with ls command but I couldnt.
Are there any way to get only files... (2 Replies)
I haven’t used Unix in over 25 years … and so I am at a loss for something that should be very simple. I have a lot of jpeg files (i.jpg) of students in a yearbook.. I also have an array name(i) of their names. I need to rename each “i.jpg” to “name(i).jpg”. I believe the ksh script... (11 Replies)
dear all.
how can i copy a list of files with different names into others directory have the same name
like i have 3 files
10_10
10_10_11
10_10_11_12
and i have 3 directories
10_10
10_10_11
10_10_11_12
how can i make a loop to cp this files into the directory have the same name like... (0 Replies)
Hi all,
I am working on a backup based script, in which it enters to a directory and check the sub-directories and copy the names into an array.
cd $CPFs
k=0
for i in *
do
if
then
ARRs="$i"
k=$(($k+1))
#echo "$i"
... (19 Replies)
I have a script that generates a variable with the location of a file and its complete path. What i want to do is to "cd" to the directory where that file is located using the path name of the file. GIS has absolutely failed me.
For example when i run my script it generates a variable called... (1 Reply)
Hi all,
I have a question. I have a folder. I want to find the list of files that are modified today and store all those file names in a variable as comma separated values. I thought of using
"find . -mtime 0" command to find the list of files modified today. Also to get those values of file... (10 Replies)