How to move file from one directory to other of only particular user?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to move file from one directory to other of only particular user?
# 1  
Old 02-17-2014
How to move file from one directory to other of only particular user?

I written unix script where a pdf file generates. But if the script is used by multiple people at a time it generates same pdf with two different owner names and creating a problem with permission while moving the file. is there a way where i can move the file filtering with the user?
# 2  
Old 02-17-2014
How about using chown to change file ownership in your script?

Or use chmod to change file permissions.
# 3  
Old 02-17-2014
it is not applicable for my application as multiple user create a same file and wich file u go and change everytime..i need to move of partivular user
# 4  
Old 02-17-2014
I am not sure if I understood your requirement.

You can get the file owner by running a stat command and move that file to user specific dir:
Code:
owner=$( stat -c %U file.pdf )

mkdir -p "$owner"

mv file.pdf "${owner}/"

# 5  
Old 02-17-2014
hi Yoda thanks for reply. Here is my code and I get variable syntax error. What is wrong here

wner=$( stat -c %$USER $prnfile.pdf )

mv $prnfile.pdf "${owner}/" /mktg/fxf05/print/dev/Freight/ReportRevSummary
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move matching file to folder in same directory

The below bash executes but nothing is copied. I am trying to cp or mv the matching .pdf to the corresponding folder. There will always be a matching .pdf found but the number of folders may vary. The portion in red is what is used to match the .pdf--- variable $pdf to the folder--- variable... (11 Replies)
Discussion started by: cmccabe
11 Replies

2. Shell Programming and Scripting

Move file from one directory and update the list file once moved.

Dears, I have a listfile contains list of files path. i need to read the line of the listfile mv the file to other directory and update the listfile by deleting the lines of the listfile. #!/bin/bash target=/fstest/INVESTIG/Sadiq/TEST_ARCH while read -r line || ]; do mv $line... (19 Replies)
Discussion started by: sadique.manzar
19 Replies

3. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

4. Shell Programming and Scripting

How I can find the last file created and move it to a directory?

I have this situation /u03/app/banjobs> ls -ltr icg* 82 Jun 12 10:37 iicgorldi_2419186.log 56810484 Jun 17 10:35 icgorldi_2421592.xml 2859 Jun 17 10:35 icgorldi_2421592.lis - 125 Jun 17 10:35 icgorldi_2421592.log 82 Jun 12 10:37 iicgorldi_2419187.log ... (8 Replies)
Discussion started by: Bernardo Jarami
8 Replies

5. Shell Programming and Scripting

Move file in to directory- script

Hi In directory /mnt/upload I have about 100 000 files (*.png) that have been created during the last six months. Now I need to move them to right folders. eg: file created on 2014-10-10 move to directory /mnt/upload/20141010 file created on 2014-11-11 move to directory /mnt/upload/20141111... (6 Replies)
Discussion started by: primo102
6 Replies

6. UNIX for Dummies Questions & Answers

move a file content to another directory

my script is: /u/user/orginal/:#! /bin/ksh find . -name "aur_prog*" -exec grep -il "error" > test.out #awk command to destination directory exit test.out file contain: ./aur_prog1.log ./aur_prog2.log ... (5 Replies)
Discussion started by: roughwal
5 Replies

7. UNIX for Dummies Questions & Answers

Finding file in a directory structure + move

Hi All, im a new guy if it comes to Unix. I am trying to auto categorize Nzbget downloads the most basic way. I already manage to find files within the directory i'm at and move them with if check to a certain dir. Unfortunately this command is restricted to the directory i'm at and does not... (2 Replies)
Discussion started by: RoxXxoR
2 Replies

8. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

9. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

10. Shell Programming and Scripting

Cron job to move file from one directory to another

Hi, I have following directory structure Media (Inside media directory I have two folders namely videos and images) -->videos -->images Inside media directory I have some video files with extension .mp4 and images with extension of .jpg and .jpeg I want to write a cron job which will... (3 Replies)
Discussion started by: tusharkale
3 Replies
Login or Register to Ask a Question