Need assistance with looping


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need assistance with looping
# 1  
Old 03-27-2015
Tools Need assistance with looping

Hi,

I have a find command that searches for all the .properties under current directory and its subdirectories.
Code:
 find . -name "*.properties"

I would like to pass the output of the above find command to my "operation.sh script as the second parameter.

for eg:
./operation.sh 775 [results of the above find command one by one]

So if the above find command returned 7 properties files the operations.sh should run 7 times taking each result as the second input.

Can you please suggest how can I ?
# 2  
Old 03-27-2015
this might work? untested..

Code:
find . -name "*.properties" | while read line
do
./operation.sh 775 "$line"
done

This User Gave Thanks to senhia83 For This Post:
# 3  
Old 03-27-2015
Quote:
Originally Posted by mohtashims
Hi,

I have a find command that searches for all the .properties under current directory and its subdirectories.
Code:
 find . -name "*.properties"

I would like to pass the output of the above find command to my "operation.sh script as the second parameter.

for eg:
./operation.sh 775 [results of the above find command one by one]

So if the above find command returned 7 properties files the operations.sh should run 7 times taking each result as the second input.

Can you please suggest how can I ?
Hello mohtashims,

Following may help you in same too.
Code:
find . -name "*.properties" -exec chmod 0775 {} +

Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assistance to use ls and GREP

Hi We have several folders and subfolders in a heirarchy, representing clients and files we send to them. Files that are not processed are placed in reject folder. I am able to run a LS that will scan all these folders, and ones that show entries (rejected files) are seen here. I am looking for... (8 Replies)
Discussion started by: cdc01
8 Replies

2. UNIX for Dummies Questions & Answers

Need assistance on using ldapsearch

Never knew of this command ldapsearch, but I would like to use it to lookup a single user and return where their office is. Is this possible? I'm totally starting from scratch. I already saw some of the gurus say read the man page, which is pretty greek when you don't know the details of... (1 Reply)
Discussion started by: srhadden
1 Replies

3. UNIX for Advanced & Expert Users

rsync assistance

Ok here we go. I have mounted remote drives and I am trying to get rsync to just sync certain directories within these mounted folders. Example: /mnt/bkmasterbackup1 /mnt/bkmasterbackup2 /mnt/bkmediabackup1 /mnt/prodnas02 /mnt/prodnas03 /mnt/prodnas04 /mnt/prodnas05 Inside these... (4 Replies)
Discussion started by: SteveMosher
4 Replies

4. IP Networking

iptables assistance

I have a CentOS 5.2 (10.20.21.73) machine that I need help with configuring iptables. According to documentation I believe this line should allow all communication between my machine and another machine (other machine has no firewall) -A RH-Firewall-1-INPUT -s 10.20.21.12 -j ACCEPT #... (1 Reply)
Discussion started by: beaker457
1 Replies

5. UNIX for Dummies Questions & Answers

Command assistance

Hi, We currently use the below basic scripts to output details that the business requires for our AIX and Sun servers. I have been asked to produce the same sort of script to be used for our NCR MP-RAS UNIX and OS/2 UNIX servers but am not formilar with these forms of Unix. Would greatly... (0 Replies)
Discussion started by: kmuir
0 Replies

6. Shell Programming and Scripting

I need an assistance

I have a school project to create a shell program same as calendar i must create a txt file with celebrations with vi i know this but the problem is i don't know awk and grep. The object of object is to create a program who read a date an appear the celebration. Can you help me please !!!... (1 Reply)
Discussion started by: mytilini boy
1 Replies

7. UNIX for Dummies Questions & Answers

Assistance needed.

the command "nawk" returns the error command cannot be found in my unix system. Is there a specific library i need to have to use this command? I tried, the whereis command and it returns nothing. if there is nothing to do, what command can i use to replace this nawk command? Appreciate some... (4 Replies)
Discussion started by: 12yearold
4 Replies

8. UNIX for Dummies Questions & Answers

Need Assistance

I have two questions I am struggling with... How do the programs p1, p2, and p3 need to handle their standard files so they can work like this: p1 | p2 | p3 ? What exactly is this command supposed to do? $ kill -QUIT %1 & This command below? $ sort -o emp.lst emp lst & Any... (1 Reply)
Discussion started by: yahoo14
1 Replies

9. Shell Programming and Scripting

regexp assistance

i have a list of text a b c d e My desired output is 'a','b','c','d','e' any advise? My file was actually in excel format, i copied out the column into notepad. I am not sure if the \n exists in between. (2 Replies)
Discussion started by: new2ss
2 Replies
Login or Register to Ask a Question