I know computers don't misbehave.
But I'm puzzled by what's happening right know in a script :
I simplified the example to point out what seems weird to me.
Don't try to find any sense to this stupid script.
There are 10 rows in /tmp/tmp.txt
In the first script, I count line from the output of sed. In the second one, I first output sed to a file and then count the lines of that file.
I see no reason why the output would be different... YET:
This is driving me crazy.
Do you have any sane explanation?!?
The first script is running sed in a subshell environment; the second is not. The subshell is a byproduct of the shell's pipeline implementation. The difference is that when $i is incremented in a subshell, the new value is not available in the parent shell.
One workaround would be to increment the variable prior to calling sed.
Regards,
Alister
These 2 Users Gave Thanks to alister For This Post:
Linux Release
Uname details
Data file
Ive been at the command line for some time. Back as far as SCO and Interactive Unix. I have always used this construct without issues. I want to isolate the ip / field 1. As you can see .. the first line is "skipped".
This works as... (6 Replies)
I have Solaris 10 update 11 installed on a virtual machine which I use for my lunix class (I'm studying I.T. but have little unix experience). So I have root access*
I'm also do C programming in my course and would love to do it on my Solaris machine.
So I looked into installing GCC and... (5 Replies)
run_xfs_fsr is a xfs filesystem maintenance script designed to run under cron. The system is a home theater personal computer running mythbuntu 10.10, and is accessed remotely for these tests. cron runs a script, (xfs_fsr.sh) at 02:30 that runs the subject script under BASH and sets the... (3 Replies)
I have the following program:
int main(int argc, char** argv){
unsigned long int mean=0;
for(int i=1;i<10;i++){
mean+=poisson(12);
cout<<mean<<endl;
}
cout<<"Sum of poisson: "<< mean;
return 0;
}
when I run it, I get the... (4 Replies)
Hi All,
Long time reader, first time poster.
I have a tip session to a v480 serial console running Solaris 9.
Look at this mess I'm getting back...
connected... (16 Replies)
Echo is removing extra blank spaces. See the command.
export INSTALLDIR=”First Second /Two Space”
echo $INSTALLDIR
out put: First Second /Two Space
Here only on blnak space is present while with command
Echo “$INSTALLDIR”
Out put: ”First Second /Two Space”
It's correct output... (2 Replies)
I have searched far and wide for an explanation for some odd behavior for output redirection and haven't come up with anything.
A co-worker was working on old scripts which have run for years and embedded in their code were output redirects which worked for the script during execution and then... (5 Replies)
the sed command:
sed 's/^*//' file
does not work on HP-UX :-( but it works fine on Linux,
content of file:
<tab><tab>hello
output should be:
hello
Any ideas??
Thank you
Andy (8 Replies)
I put this here because it is a 'behavior' type question..
I seem to remember doing ls .* and getting all the .-files, like
.profile
.login
etc.
But ls .* doesn't do that, it lsts the contents of every .*-type subdirectory.
Is it supposed to?
I should think that a -R should be given to... (10 Replies)