Since ls is run twice, there's a race condition. If a directory is deleted in the meantime, a directory that should have been kept will be nuked. Similarly, if a directory is added in the meantime, a directory that should have been removed will persist.
There is no need to run ls twice. You can just use tail's ability to index releative to the beginning of the data, tail -n +10 versus tail -n 10. However, this approach still requires some arithmetic, since skipping the first x lines requires an option argument of x+1.
I wouldn't bother with tail. In my opinion, the simplest solution is to use sed:
Note that xargs does not play well with filenames containing whitespace or quotes. If such filenames occur, instead of xargs, a less efficient while-read loop would be necessary.
Regards,
Alister
What is the command to remove files that are generated 6 hours or older? The find and remove tells only how to remove if the file is one day old or more. Appreciate quick reply. Thanks (3 Replies)
Hi all,
I have an H80 that I'm migrating to 5.3 and prior to doing so it needed the firmware upgraded. I don't have copies of the old firmware that was on it since I was not the one who installed it and there were no copies to be found on the server itself. I installed the latest version and... (4 Replies)
Script help, I need to delete files that are older than 7 days. I do that automatically but I know that a cron job can do the job for me. Any help is greatly appreciated, as you can see, I am a DOS or WINDOWS guy. Little on UNIX. Thanks (3 Replies)
Hi All,
.profile has been replaced with a new one. I need to know the variables used in the older version of .profile. I have a session opened using the old .profile.
Is there a way that I can get the exact file.
I had some luck by using set command. But is there any way that I can get the... (5 Replies)
When I am trying to use below code of for loop on older version of ksh
it not working,and I just want to use only FOR loop
-----------------
for i in (1..5)
do
echo $i
done
-----------------
please suggest.it really stoping me.
FYI: i want to do this only by for loop (2 Replies)
Hi,
I am trying to downgrade the version of rsyslog to the older version (i.e) and when i issue the below command to check the packages i dont see the required package (i.e)
and when i try to install it is complaining about package not found.
Please advise on how to install the... (1 Reply)
Which older version and variant of Debian Linux ISO image should I use?
I attempted to install two versions of Debian Linux Operating System
onto my older full tower computer.
First version, V8.5.0, Amd64, xfce, 32Bit.
Second version V7.11.0, i386, 32Bit.
When trying to install... (1 Reply)
Hello, I'm running Ubuntu 18.04 and I would like to install libboost-python version 1.46. Currently I have installed version 1.65:
wakatana@local-machine:~$ dpkg -l | grep libboost-python
ii libboost-python-dev 1.65.1.0ubuntu1 amd64 ... (1 Reply)
Discussion started by: wakatana
1 Replies
LEARN ABOUT OPENSOLARIS
mvdir
mvdir(1M) System Administration Commands mvdir(1M)NAME
mvdir - move a directory
SYNOPSIS
/usr/sbin/mvdir dirname name
DESCRIPTION
mvdir moves directories within a file system. dirname must be a directory. If name does not exist, it will be created as a directory. If
name does exist, and is a directory, dirname will be created as name/dirname. dirname and name may not be on the same path; that is, one
may not be subordinate to the other. For example:
example% mvdir x/y x/z
is legal, but
example% mvdir x/y x/y/z
is not.
OPERANDS
dirname The name of the directory that is to be moved to another directory in the filesystem.
name The name of the directory into which dirname is to be moved. If name does not exist, it will be created. It may not be on the
same path as dirname.
USAGE
See largefile(5) for the description of the behavior of mvdir when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
EXIT STATUS
0 Successful operation.
>0 Operation failed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO mkdir(1), mv(1), attributes(5), largefile(5)SunOS 5.11 14 Mar 1997 mvdir(1M)