08-14-2014
The current standard says:
Quote:
A subshell environment shall be created as a duplicate of the shell environment, except that signal traps that are not being ignored shall be set to the default action. Changes made to the subshell environment shall not affect the shell environment. Command substitution, commands that are grouped with parentheses, and asynchronous lists shall be executed in a subshell environment. Additionally, each command of a multi-command pipeline is in a subshell environment; as an extension, however, any or all commands in a pipeline may be executed in the current environment. All other commands shall be executed in the current shell environment.
So, variable assignments in a while loop in a pipeline are allowed, but not required, to be visible in the current shell execution environment after the pipeline terminates.
The last element of a pipeline is run in the current shell execution environment in
ksh.
The last element of a pipeline is run in a subshell environment in
bash.
On this point, both are OK according to the standard.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I need to do the following:
1) find files in certain directories that have todays date stamp
2) use these files as input arguements into another command (1 Reply)
Discussion started by: bobbygrep
1 Replies
2. Shell Programming and Scripting
Hello
I was wandering if I can combine find command in side for each loop in unix
the main propose is to change some thing in files from several types and not all of them
is this possible ? (on liner script? )
tnx for the helppers (3 Replies)
Discussion started by: umen
3 Replies
3. Shell Programming and Scripting
I have the following statement in script:
find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do
...
done
When there are no files located by the find comand it returns:
"find: bad status-- /home/rnitcher/test/....." to the command line
How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies
4. Shell Programming and Scripting
Hi,
'read' command is not working inside the while loop, How can I solve this?
Rgds,
Sharif. (2 Replies)
Discussion started by: sharif
2 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script.
I am planning to do like this:
if ; then... (2 Replies)
Discussion started by: new_learner
2 Replies
6. UNIX for Advanced & Expert Users
HI ,
I am trying to wite a script that will prompt me saying " what is path that you want to find ?". once i specify the path, the script should put this path in the find command mentioned below and execute the script:
find <path> -ctime +200 -type f -exec ls -l {} \;
for example :
... (7 Replies)
Discussion started by: bsandeep_80
7 Replies
7. Shell Programming and Scripting
Test - Test (1 Reply)
Discussion started by: Amit Sura
1 Replies
8. Shell Programming and Scripting
Hello friends,
I want a command to print the reult files from find command into a text file.:)
Iam looking from forum memebers. PLZ help me.ASAP
Thanks in Advance,
Siva Ranganath CH (5 Replies)
Discussion started by: sivaranga001
5 Replies
9. UNIX for Dummies Questions & Answers
i have executed the following command in terminal
find /Users/vasu -name "*.txt" -print
and i am getting the result
/Users/vasu/file1.txt
/Users/vasu/file2.txt
/Users/vasu/file3.txtbut while i was trying to execute the same in the script it is not working,I tried with below logic in... (2 Replies)
Discussion started by: vmachava
2 Replies
10. Shell Programming and Scripting
Hi guys!
Kind of new to bash scripting and now I'm stuck.
I need to curl with these variables:
"{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }"
and my input_file.txt contains
server001 10.10.10.01 serverpool1 80... (4 Replies)
Discussion started by: yort
4 Replies
command(1) General Commands Manual command(1)
NAME
command - Treats command arguments as simple commands
SYNOPSIS
command [-p] command_name [argument...]
command [-v | -V] command_name
The command command causes the shell to treat the arguments to command as simple commands, and suppresses the default shell function
lookup.
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
command: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Performs the command search using a default value for PATH that is guaranteed to find all of the standard utilities. Writes a string to
standard output that indicates the path name or command to be used by the shell in the current shell execution environment to invoke com-
mand_name. Writes a string to standard output that indicates how the name given in the command_name operand will be interpreted by the
shell in the current shell execution environment.
DESCRIPTION
The command command allows you to run the following commands: User-defined commands whose names correspond to shell built-in commands.
System commands whose names correspond to shell built-in commands.
The command_name argument specifies the name of a utility. The one or more optional arguments to command_name specify strings treated as
arguments to the specified utility. It also provides information concerning how a command name will be interpreted by the shell.
NOTES
[Tru64 UNIX] If command_name is not the name of a function, the effect of command is the same as would be obtained by specifying com-
mand_name without command.
RESTRICTIONS
Since the -v and -V options to command produce output in relation to the current shell execution environment, if command is called in a
subshell or separate utility execution environment, it may not produce correct results. The following are examples of this type of opera-
tion:
(PATH=foo command -v) nohup command -v
EXIT STATUS
When the -v or -V options are specified, command returns one of the following values. Successful completion. The command_name could not
be found, or an error occurred.
If the -v or -V options are not specified, command returns one of the following values on error. The utility specified by command_name was
found but could not be invoked. An error occurred in the command command, or the utility specified by the command_name argument could not
be invoked.
If no error occurs, the exit status of command is that of the command specified by the arguments to command.
EXAMPLES
To ensure execution of the simple command pwd instead of the pwd shell built-in command, enter the following: command -p pwd
The preceding command displays the full path name of the current directory, and does not perpetuate a view of the current directory loca-
tion created by links as the shell built-in command might do.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of command: 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
variables contains 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 that
should be used to affect the format and contents of diagnostic messages written to standard error. Determines the location of message cat-
alogues for the processing of LC_MESSAGES. Determines the search path used during the command search unless the -p option is specified.
SEE ALSO
Commands: env(1), hash(1), type(1)
Standards: standards(5)
command(1)