Sponsored Content
Top Forums Shell Programming and Scripting Foreach loop with two variables Post 302950658 by vgersh99 on Monday 27th of July 2015 05:45:56 PM
Old 07-27-2015
does it have to be csh/tcsh?
Code:
#!/bin/ksh
awk '
   FNR==NR {f1[$0];next} 
  {f2[$0]}
END {
   for (f1I in f1)
     for (f2I in f2)
       print "sql " f1I " -u" f2I " <script.sql>> script.log"
}' /local/hd3/dba/tools/build_db_scripts/dbs /local/hd3/dba/tools/build_db_scripts/dbas > /local/hd3/dba/tools/build_db_scripts/run_this

chmod 777 /local/hd3/dba/tools/build_db_scripts/run_this

This User Gave Thanks to vgersh99 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

foreach loop question

Hello, I am new at this forum so please bare with me on this. Within a given directory, I have a list of files in which in each file, I would like to do a substitution. I would like to substitute the string mlcl to mll in each file using the foreach command. I dont quite get how to do that. If... (7 Replies)
Discussion started by: clipski
7 Replies

2. Shell Programming and Scripting

Foreach loop

What am I doing wrong with this foreach loop? foreach var ($argv) @sum = $sum + $var (4 Replies)
Discussion started by: haze21
4 Replies

3. Shell Programming and Scripting

foreach loop

Hi Guys, I have a loop which uses a wildcard i.e. foreach f (*) but when I execute the tcsh file in unix then it gives me an error ->>>>>>>foreach: words not parenthesized<<<<<<<<<<- Any help. (1 Reply)
Discussion started by: abch624
1 Replies

4. Shell Programming and Scripting

foreach loop + 2 variables

In a foreach loop, is it possible for the loop to go through 2 arguments instead of one i.e. instead of foreach i (do stuff for i), we have foreach i j(do stuff for i; do stuff for j) I am working under BASH and TCSH shell environments cheers (3 Replies)
Discussion started by: JamesGoh
3 Replies

5. Shell Programming and Scripting

foreach loop

Hi everyone Does anyone know what is wrong with this script. i keep getting errors foreach filename (`cat testing1`) set string=$filename set depth=`echo "$string" echo $depth end the error is the following testing: line 1: syntax error near unexpected token `(' testing: line 1:... (3 Replies)
Discussion started by: ROOZ
3 Replies

6. UNIX for Advanced & Expert Users

Problem with foreach loop

Hi All, Is there any problem with the below 'foreach' loop? foreach risk_factor ($(cat "$rf_list")) where "rf_list=$SCRIPT/Utility/rflist.txt " I'm wondering, it is throwing below error message: syntax error at line 34: `(' unexpected Any idea/suggestions ? Thanks in advance /... (7 Replies)
Discussion started by: ganapati
7 Replies

7. Shell Programming and Scripting

Using sed with a foreach loop

So I am back again beating my head against the wall with a shell script and getting a headache! I want to change each year in a file (1980, 1981, 1982, 1983, etc.) to the same year followed by a tab. The input is "blah blah (1980) blah blah". I want to get "blah blah (1980 ) blah blah".... (2 Replies)
Discussion started by: Peggy White
2 Replies

8. UNIX for Dummies Questions & Answers

Using the Foreach loop, Needing help

I am trying to make a script for my Counter-Strike: Source servers. What i am wanting it to do is for it to restart each server, the only way i can think of doing this in through for each. Years what i have at the moment. server_start() { START=`ps x | grep SCREEN | grep $SRV | cut -d '?' -f... (5 Replies)
Discussion started by: grahamn95
5 Replies

9. Shell Programming and Scripting

foreach loop problem

Dear all, I wrote a script to download files and move files in directories according to their name. Now here is the problem: Both p101 and p360 data download successfully, but when I move them according to the year and month, only p101 data can be placed at the right location, p360,... (1 Reply)
Discussion started by: handsonzhao
1 Replies

10. UNIX for Dummies Questions & Answers

foreach loop in csh

Hi everyone I'm new to unix and encountered a small problem i couldnt find out a reason why it doesn't work..please help.. in my csh script when i tried to use the foreach loop like this: foreach x ( ls ) echo $x end when i tried to run it, it printed out 'ls' to the std out instead of... (3 Replies)
Discussion started by: ymc1g11
3 Replies
chown(1)						      General Commands Manual							  chown(1)

NAME
chown - Changes the owner of files or directories SYNOPSIS
chown [-fhR] owner [:group] file... The chown command changes the owner of the specified files or directories to the specified user name or user ID. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: chown: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
[Tru64 UNIX] Turns off error reporting. [Tru64 UNIX] If file is a symbolic link, chown -h file changes the owner of the symbolic link. The chown file format changes the owner of the file referenced by the symbolic link. Descends recursively through its directory arguments, setting the specified owner. OPERANDS
The pathname of the file for which ownership is to be changed. A user ID and optional group ID to be assigned to file. The owner portion of this operand must be a user name from the user database or a numeric user ID. Either specifies a user ID to be given to each file named by one of the file operands. If a numeric owner operand exists in the user database as a user name, the user ID number associated with that user name will be used as the user ID. If the group portion of this operand is present, it must be a group name from the group database or a numeric group ID. Either spec- ifies a group ID to be given to each file. If a numeric group operand exists in the group database as a group name, the group ID number associated with that group name will be used as the group ID. DESCRIPTION
[Tru64 UNIX] Only a user with superuser authority can use the chown command. The owner argument must be a valid user name or a valid numerical user ID. The optional group argument must be a valid group name or a valid numerical group ID. EXIT STATUS
The following exit values are returned: The chown command executed successfully and all requested changes have been made. An error occurred. EXAMPLES
To change the owner of the file program.c, enter: chown steffan program.c The user access permissions for program.c now apply to steffan. As the owner, steffan can use the chmod command to permit or deny the other users access to program.c. See the chmod command for details. ENVIRONMENT VARIABLES
The following environment variables affect the execution of chown: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. FILES
Contains user names and numeric user IDs. SEE ALSO
Commands: chgrp(1), chmod(1), passwd(1) Functions: chown(2), chmod(2) Files: passwd(4) Standards: standards(5) chown(1)
All times are GMT -4. The time now is 08:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy