first of all, don't hesitate to notify me if I misbehave. I'm a newbe in the use of this site, and in unix too (in english as well :-)
Well, if someone hat a little time to waste, could he explain to me this strange behavior.
I'm using ksh under AIX.
This works fine. But the following doesn't :
Nothing echoed...
I can't understand.
works fine... A string is sent to STDOUT.
Redirected to 'grep', that shoul work no ?
OK, thanks for reading...
JC
Moderator's Comments:
Please use code tags next time for your code and data, thanks
The second version "loses" carriage control: the \n characters are not there. So all of the output is one single line that grep will not print because it has 'code page' in it. The first example creates multiple lines of output as your example shows
Please post the result of echo "$(su - db2inst1 -c 'db2 get db cfg')" with and without double quotes.
Could you put the pipe to grep into the command substitution?
I made different searches in google. I found, this afternoon, what seems to be a bug in a ksh version. They say that it's impossible to put a pipe inside the command substitution. But for me, this can't be the problem. That works with this for instance :
Thanks to you all. I'm going to consider and give a try to Jim suggestion... I keep on searching...
The grep utility is defined to work on text files. By definition, a text file contains lines that are no longer than LINE_MAX bytes (2048 on many systems). When you quote the expansion of your variable, the lines are preserved and no line fed to grep is longer than LINE_MAX. So:
works and:
should also work with no problems. But:
(with no quotes around the expansion of $cdeset) feeds one very long line to grep and produces unspecified results. (No output is a valid result in this case. Printing the entire long line is another valid result in this case. Printing a diagnostic message saying the input is not a text file is a valid result in this case. Printing a line saying: bad programmer is another valid result in this case, although I don't know of any version of grep that implements this option.)
The Korn shell (i.e., ksh) does not have any problem with pipelines inside command substitutions as long as the data fed through the pipeline is in a format that is suitable to each of the commands in the pipeline. Feeding data through a pipeline in a format that is not valid for a command reading it in a pipeline might or might not work in a command substitution and might or might not work in a pipeline outside of a command substitution. I don't know of any shell where a pipeline inside a command substitution would behave differently than the same pipeline outside a command substitution (other than side effects affecting the current shell execution environment will disappear when a pipeline in a command substitution completes).
Hi Guys,
I need to replace the string based on specific value by keeping dollar sign
input=$1
var=$(echo "@code_temp_table_$value_table"| sed -r "s/\@code/${input}/;s/(nz|sa)_\$value_/\$value1_\1_/" )
Expected
if
input=nz,sa
then
nz_temp_table_$value1_table
else
if any other... (5 Replies)
Hi experts. I want to setup a training lab.
I have a Power 5 standalone server 9110-51A (p5 510)
I want to enable PowerVM on it and create two LPARs
I don't have money for an HMC
I know I can use IVM instead
I understand IVM is part of the VIOS software
TWO QUESTIONS:
1- If... (12 Replies)
hi,
I have been trying to acheive the following task for a while now, but failed.. Need help, experts please help!
This is what I am trying to do:
- I am writing to a flat file the name of the source to be copied and the destination path as to where it is to be copied to.
Sample flat file:... (7 Replies)
Hi,,
Let example cmd: $$config/all
Here I want to replace or subsitute blank space and also with any other character in place of "$" sign...and also want to replace backslash (/) with forward (\)......in expect script
please could any one help on this.....thank you (2 Replies)
Hi,
I have a problem in dollar substitution:-
$ csv1="first_csv"
$ csvnumber=1
$ echo {csv$csvnumber}
{csv1}
$ echo "${csv$csvnumber}"
bad substitution
I want first_csv...why is it not working
thanks (2 Replies)
I was just a-wondering through some hardware and software sites, and in one of them, I was scrolling down a UNIX os page when I noticed that the prices for these OS's were climbing alarmingly high; in the 5 to 10 G's.
Imagine my surprise when I saw one particular UNIX os selling for 65 freakin'... (10 Replies)
I get a transaction file and I need to sum two of the columns. I each record I get a debit(D) or credit(C) indicator. Then I get an amount field. I need to sum the total dollar value of debits and credits.
I know I can loop through each record and get the sum total but is there a better way with... (7 Replies)
All,
How can I get unix to handle the symbol $ as text rather than thinking its a variable value.
e.g When calling a sql script from unix:
exec SQL_PACKAGE('OPS$JOHN.EMP')
where OPS$JOHN is the owner of the table ($JOHN is not a variable!)
Thanks (1 Reply)