Sponsored Content
Top Forums Shell Programming and Scripting how to list files and execute an action? Post 302362577 by bbbngowc on Friday 16th of October 2009 01:42:22 PM
Old 10-16-2009
how to list files and execute an action?

I'm not sure how to word what I'm trying to do.

I would like to:

1. Generate a list of files (easy to do ls -l > list.txt)
2. Carry out an action again each file in the list (not so easy to do)

Like:

List all files in /dir and then execute a move of each file individually. something like:

mv file1 /dir2
mv file2 /dir2
mv file3 /dir2

I know I can carry out a move with

Code:
"find . -type f -name "file" -exec mv {}"

but I'm trying to find a work around to something else and I think this may be it.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in searching 2 files for strings then perform an action

I have 2 files. I basically want to search both of them to see if the 1st column ($1) matches and if it matches then check to see if the 2nd column ($2) matches, then execute some code showing the results of the matches. File 1: AAA 123 misc blah BBB 456 CCC 789 File 2: ... (2 Replies)
Discussion started by: streetfighter2
2 Replies

2. UNIX for Dummies Questions & Answers

how to use expect - send to execute list of commands inside a file

:)hello people i am working on some kind of PBX and i have list of telephone numbers inside a file, i have to insert these numbers into the correct command and then telnet to a remote server and execute these commands. i can read the telephone numbers and insert them into the command with no... (0 Replies)
Discussion started by: auma78
0 Replies

3. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

4. Shell Programming and Scripting

How to access files from different directories and to perform search action in those files?

Hi, I want to access files from different directories (for example: /home/dir1/file1 , /home/dir2/file2 ...) Like this i have to access these files(file1, file2...). (3 Replies)
Discussion started by: bangarukannan
3 Replies

5. Shell Programming and Scripting

sed cannot execute [Argument list too long]

Hi All, This question has been asked many times, but my problem is slightly different. In my shell script i am connecting to oracle database and loading the results to .dat file. This .dat file is later used to create to .xls file Some times the size of .dat file becomes more than 120000... (8 Replies)
Discussion started by: galaxy_rocky
8 Replies

6. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies

7. Shell Programming and Scripting

Find files and execute commands on these files (advanced)

So, I need to find a bunch of files and delete them (this example, but sometimes I need it for something else) and my trusty go-to command has always been: find . -type f -name '*file*' | xargs -I## rm '##' Works wonders... But: touch file\ file\'.txt touch file.txt touch file\ file.txt... (6 Replies)
Discussion started by: Mr.Glaurung
6 Replies

8. Shell Programming and Scripting

Find list of files missing read & execute permission

Hi, I'm writing a post-upgrade script and I want to find which files don't have read and execute to everyone. I can run a find . ! -perm, but then I have to use a list of the possible permissions (777,775, 755 etc). Is there a more elegant solution? Thanks (2 Replies)
Discussion started by: Catullus
2 Replies

9. UNIX for Beginners Questions & Answers

Action on all files in a folder

How can I do an action to all files in a specific folder? Do I use ls and a loop or something else? Does ls take folder location? (2 Replies)
Discussion started by: locoroco
2 Replies
dop(8)							      System Manager's Manual							    dop(8)

NAME
dop - Allows a user to execute a privileged program without knowing the root password. The dop command also modifies the action database. SYNOPSIS
/usr/sbin/dop [-n | -N] [ui:] action [args] /usr/sbin/dop -a priv[,priv]... action [ui:]pathspec[,[ui:]pathspec]... /usr/sbin/dop -a priv[,priv]... [ui:]pathspec /usr/sbin/dop -d action /usr/sbin/dop [-w | -W] OPTIONS
Invokes a prompt asking the user if they want to run the command as a user or as root. The root password is required to run as root. Attempts to run the action with the user privileges. Adds new actions to the dop database. Deletes an existing action from the dop data- base. Writes a binary image without changing the source. Updates the actionlist from the dop action file and then executes the -w option, which writes the binary image. OPERANDS
Name of privileged program to invoke Arguments to pass to the application guarded by the privilege. Comma separated privilege list (see sysman dopconfig) The fully qualified path name and arguments for the associated action. When specified by a comma separated pathlist and arguments for multiple user interface domains (ui:), the first ui: argument speci- fied is used as the default. If no action is specified, then the path base name is used. A run-time argument replaces the first occurrence of asterisk as a word (for example *) in a string, or else they are ignored. Path arguments should be quoted per the cur- rent shell. Optional. A user interface domain, typically one of X11, suit, java, menu, cui, or cli. DESCRIPTION
The dop (Division of Privileges) command can execute an action after proper authentication from the privilege database file. For more information, see the Security guide. RESTRICTIONS
You must have root privileges to modify the privileges database. EXAMPLES
The following example will add an action to the AccountManagement privilege. dop -a AccountManagement adduser_script /usr/sbin/adduser The following example runs the action adduser_script for the AccountManagement privilege. dop adduser_script The following example deletes the adduser_script action from the action database. dop -d adduser_script FILES
Executable file. Executable file for adding or deleting permissions for users and or groups. dop database. SEE ALSO
Commands: sysman(8) dop(8)
All times are GMT -4. The time now is 09:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy