Sponsored Content
Top Forums UNIX for Advanced & Expert Users [Discussion] POSIX, the Love of Backticks and All That Jazz Post 302990520 by MichaelFelt on Friday 27th of January 2017 01:20:59 PM
Old 01-27-2017
Quote:
Originally Posted by MadeInGermany
Then let me continue with lession#2.
Within $( ) there is a parser problem with the old style case statements.
Code:
#!/bin/bash
res=$(
  case $1 in
  1) echo 1;;
  esac
)
# syntax error in bash3 and ksh88
# workaround:
# (1) echo 1;;
echo "$res"

But bash4 and ksh93 have got a fix.
Bash is not standard on AIX. And many people I see using bash are using bash-4.2 not 4.4 - so when you say bash4 - do you mean any bash-4.X or are you talking about the X (again, most people just say bash - not bashX).

So, maybe - we should split this off - but please come up with a catchy "subject line" - as we are sort of "all over the place" - shells, POSIX, environments, ...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - backticks v system in if statements

Can someone explain the difference between backticks and system when evaluated in these if statements: sub getDate { print "start date\n"; if ( system("/bin/date") ) { print "can't get date\n"; exit(2); } print "finish date\n"; } Returns the following: start date Thu... (5 Replies)
Discussion started by: gjkeenan
5 Replies

2. Shell Programming and Scripting

Backticks within backticks?

Hi, I'm trying to do something like this: range= `expr `date '+%m'` - 1` and it does not work. How can I tell it to evaluate an expression within another expression evaluation? I was at first worried that `date '+%m'` would return a string but apparently expr does the math okay normally, so the... (3 Replies)
Discussion started by: jeriryan87
3 Replies

3. UNIX for Dummies Questions & Answers

sed: removing backticks from certain lines

Hi, I would like to change some lines in my mysql-dump, because there a syntax problems with some version of mysql. I 'd like to change USE ´someDatabase´; to USE someDatabase; (without backticks) using the sed command in the shell Thanks & best regards Bernd (5 Replies)
Discussion started by: bjb
5 Replies

4. Shell Programming and Scripting

Am I abusing backticks?

I'm always concerned I might be abusing backticks within my scripts. A current script I'm writing has this for example: stripscriptname=`echo $scriptname | sed 's/\(.*\)\..*/\1/'` stripsearch=`echo $searchpattern | tr -d ' ,/'` Both of these variables are set inside the script (in fact,... (2 Replies)
Discussion started by: mglenney
2 Replies

5. Shell Programming and Scripting

Difference between using xargs and backticks

Hey all. Just a fast question, what is the technical difference between using back ticks and using xargs to perform a command? Here's an example Find /mydir -name *.conf |xargs rm Vs Rm 'find /mydir -name *.conf' Is there a performance hit? I know they do the same thing but which is... (1 Reply)
Discussion started by: msarro
1 Replies

6. Red Hat

perl backticks: can't redirect output.

Hi everyone. This is a bit of a perl/linux mixed question. I am trying to redirect STDOUT of chsh by using the following line of perl code. system ("chsh -s /sbin/nologin $testing 1>/dev/null"); This should redirect STDOUT to /dev/null but it won't do that for some odd reason. Any ideas or... (6 Replies)
Discussion started by: austinharris43
6 Replies

7. Shell Programming and Scripting

Help with remove backticks in a text file

Input file: 'data_1' 'data_10' 'data1311' '235data_13' Desired output: data_1 data_10 data1311 235data_13 Can I know how to remove back tick"'" in a file? Many thanks for advice. (3 Replies)
Discussion started by: perl_beginner
3 Replies

8. Shell Programming and Scripting

SSH and Backticks [solved]

I have been testing a new script and cannot figure out why my `cat spath` will not execute on the remote machine? sudo ssh -p 22344 -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.1.6 "find `cat spath` -depth" cat: spath: No such file or directory but... (0 Replies)
Discussion started by: metallica1973
0 Replies

9. Shell Programming and Scripting

Nesting backticks

I'm trying to make a dialog window that prints the output of grep that takes the output of find. Unfortunately my nested backticks don't work. Here is the dialog window: dialog --stdout --title "test" --backtitle "test" --msgbox "Test:\n `grep -l "${tablica}" `find $string``" 16 60I think I... (2 Replies)
Discussion started by: Starting_Leaf
2 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)
All times are GMT -4. The time now is 01:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy