I need my script to choose a random folder within a folder and set that folders name as a variable.
I can list all folders within a folder using
Say my folder structure is
folder
|____folder01
|____folder02
|____folder03
By using the code above I can list the folders as so.
The randomly-selected file is: /folder/drwxr-xr-x 2 user user 4096 2012-04-14 14:53 folder01
drwxr-xr-x 2 user user 4096 2012-04-14 14:53 folder01
/folder/drwxr-xr-x 2 user user 4096 2012-04-14 14:53 folder01
I just want it to display 'folder01' and not 'drwxr-xr-x 2 user user 4096 2012-04-14 14:53 folder01'
Any help would be greatly appreciated.
Cheers
DV
---------- Post updated at 03:10 PM ---------- Previous update was at 02:25 PM ----------
I think the issue is with this command
ls -1 /folder/
I just need this command to just list directories and not files.
Last edited by digitalviking; 04-14-2012 at 11:06 AM..
Hi,
I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content.
for example... (3 Replies)
Hi Team,
I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.
Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338
Subfolder will be always with timestamp... (6 Replies)
I need help to write shell script to copy files from one server to another server.
Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Hi,
I have 200 pictures in a folder and I would like move 10 random pictures every week to given folder automatically.
I have this server on 1and1.com.
So I tried the following using Bash script for manual copy and paste for testing
#!/bin/bash
mapfile -t -n 3 files < <(find... (13 Replies)
This is the file structure:
DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg
DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg
DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg
DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg
DESKTOP/Root of Photo... (4 Replies)
Hello,
I am an amature at UNIX commands and functionality.
Please could you all assist me by replying to my below mentioned querry :
How can I upload a zip folder on a unix path from my windows folder?
Thanks guys
Cheers (2 Replies)
Hi all,
I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt.
I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Hello all,
I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written.
I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)