You should ALWAYS check user input - consider it toxic if that helps.
This is something I always do. Like I said, the variables contain the path to existing directories. They're checked before using the mv, but I skipped that part in order to focus on the permissions question.
Quote:
Originally Posted by jim mcnamara
You should ALWAYS check user input - consider it toxic if that helps.
If you use linux the -empty test works for what you want - you do not mention your system or shell
You're right, I'm sorry I didn't mention it. My shell is Bash, and I use GNU coreutils, but the script is meant to be POSIX-compliant, hence the use of the single square bracket test.
Quote:
Originally Posted by jim mcnamara
You can also use the ls command more globally
I know this is off-topic, but this is also one of the cases I don't know what the best practice is, because the standard states that the -A "writes out all directory entries, including those whose names begin with a <period> ( '.' ) but excluding the entries dot and dot-dot (if they exist)". But then there's the HP-UX ls, where "for a user with appropriate privileges, this flag defaults to on, and is turned off by -A". What should I do in this case?
Quote:
Originally Posted by MadeInGermany
In order to move a file the directory is modified i.e
must be writable. The file permissions do not really matter, while in an interactive shell the mv might become interactive i.e. ask.
So either test
Or make them writable
A trailing / will automatically follow a symlink and test for a directory.
The chmod and the -d test always follow a symlink.
(Nevertheless the chmod targets should have trailing / to ensure they are not files.)
The -v (verbose) option can be captured in a file or a variable.
I see. But if the variables are checked with [ -d "$directory" ] && [ -d "$destination" ], the railing slash is not needed, right?
What I need to do is: I need to use the grep command to search for pattern in directory and sub-directories. And also I need to show the permission of file been seached by the grep command.
Could any one please suggest me?
-----------------
$> cat file1.txt
A
-----------------... (8 Replies)
I am new to shell scripting. Can someone help me out with this one please?
I need to write a script fot the following scenario:
I am currently in /parent directory.
I have a set of files in /parent/error_files directory
My script has to search for a file in /parent/erratic_files... (1 Reply)
hello,
I have to write a script to run the other script inside it.So iam planning to write like this?
first check the perimissions of the file.
Alogorthim
----------
if(!filepermissions == execute)
then
echo" Permissions denined"
else
execute the script.
file name is : load_mf.sh... (1 Reply)
Hi
I am want to create a script where the file gets moved from the current folder to a folder transfer based on the oldest first. This script should run one file at a time using a loop. I want it as a loop because I want to do some processing while I have one file. Can anyone guide me on this? (2 Replies)
Hi,
I have a directory having so many number of files. Now I want to move the files which are older than one month (lets say) from this directory to another directory (say BKP dir).
Simply, if file is olderthan one month move it from source1 dir to BKP1 dir.
My file names doesn't have... (7 Replies)
Hi,
For a particular set of files, am trying to check if they are writable. i.e., checking whether they are having permissions greater than 755.
Am able to check this using the statement:
"if (os.path.isfile(FILE_PATH) and (os.stat(FILE_PATH).st_mode & 0777) == 0777):"
But the problem here... (0 Replies)
Hi,
For a particular set of files, am trying to check if they are writable. i.e., checking whether they are having permissions greater than 755.
Am able to check this using the statement:
"if (os.path.isfile(FILE_PATH) and (os.stat(FILE_PATH).st_mode & 0777) == 0777):"
But the problem... (1 Reply)
Hi All,
I have multiple files in the folder, I want to move those files into the other folder on based of name
File names:
Template_server1_01==>
Template_server1_02==>To one directory /Server1
Template_server1_03==>
Template_server2_01==>
Template_server2_02==>To one... (9 Replies)
Is there a way to check when the permissions for the file got changed in AIX
IS there some file which logs all these details?
Best regards,
Vishal (4 Replies)
This is the content of my directory
c_g_se1_gb.ph
c_g_se1_gb.ph_pl_s.t
c_g_se1_gb.ph_pl_tr.t
c_g_se3_gb.ph
c_g_se3_gb.ph_pl_s.t
c_g_se3_gb.ph_pl_tr.t
c_g_se2_gb.ph
c_g_se2_gb.ph_pl_s.t
c_g_se2_gb.ph_pl_tr.t
c_g_se4_gb-1.ph
c_g_se4_gb-1.ph_pl_s.t
c_g_se4_gb-1.ph_pl_tr.t... (9 Replies)