The main shell forks off a copy of itself to run while read independently of the echo so they can both run while connected by a pipe. The copy, or "sub-shell", runs successfully, setting all your variables and such as you please, until the pipe runs out of information and returns EOF. Then the loop quits.
Then the subshell dies. Control is returned to the main shell, which remains unchanged. You set all your variables in the subshell, not the main one.
In short: It's the pipe that does it. Your shell and everything behind the pipe are different processes and don't share variables.
Pipes are overkill if you have substring operators anyway. This way of getting a single character ought to work identically in bash and ksh:
Hi,
I have file abc.txt which has keys and emails addresses
abc.txt
emailkey1:sam@abc.com
emailkey1:tom@abc.com
emailkey2:rqw@abc.com
emailkey2:tut@abc.com
I have a shell script where i pass key as the parameter and i want all the email addresses within that key concatenated by a comma... (21 Replies)
I have a set of variables:
f1="./someFolder"
.
.
f10="./someOtherFolder"
And I'm trying to use the following loop
for (( i = 0; i <= 10; i++ ))
do
temp=f$i
done
I'm trying the get the values from my set of variable to make directories, but I can't seem the get those value... (3 Replies)
- I m retreving values from database and wish to use those values later in my shell script. I m placing these values in an array da_data but outside loop array is empty.Problem is its treating array as local inside loop hence array is empty outside loop.
Plz go through the script and suggest how... (1 Reply)
I need to do something like this:
for i in 1 2 3 4 5; do
arr=$(awk 'NR="$i" { print $2 }' file_with_5_records)
done
That is, parse a file and assign values to an array in an ascending order relative to the number of record in the file that is being processed on each loop.
Is my... (2 Replies)
I'm a programming noob. I'm trying to run a memory intensive process for many files. But when I use the following script, it runs fine for the first 5-7 files, then runs out of memory. Monitoring the output files, it's clear the processes are going on in parallel. Once 5-7 of the files are being... (18 Replies)
Hi All
I am trying to fetch the size of three files into three separate variables within a for loop and am doing something like this:
for i in ATT1 ATT2 ATT3
do
size_$i=`ls -ltr $i | awk '{print $5}'`
echo ${size_$i}
done
but am getting the below error:
ksh: size_ATT1=522: not... (3 Replies)
array=( 8 5 6 2 3 4 7 1 9 0 )
for i in "${array}"
do
echo $i
done
# i need the output like this by swapping of array values
0
9
1
7
4
3
2
6
5
8 (7 Replies)
I have a headerless array of 1000 columns x 100000 rows. The array only contains 4 values; 0/0, 0/1, 1/1, ./.
Here I am showing the 1st 3 rows and columns of the input array
0/0 0/0 1/1
0/1 0/1 0/1
0/0 ./. 0/0
0/0 0/0 0/0
I would like to convert the values in... (9 Replies)
Hello!
I'm making an English to Morse Code translator and I was able to mostly get it all working by looking through older posts here; however, I have one small problem.
When I run it it's just printing spaces for where the characters should be. It runs the right amount of times, and if I try... (3 Replies)
Discussion started by: arcoleman10
3 Replies
LEARN ABOUT DEBIAN
io::async::looptests
IO::Async::LoopTests(3pm) User Contributed Perl Documentation IO::Async::LoopTests(3pm)NAME
"IO::Async::LoopTests" - acceptance testing for "IO::Async::Loop" subclasses
SYNOPSIS
use IO::Async::LoopTests;
run_tests( 'IO::Async::Loop::Shiney', 'io' );
DESCRIPTION
This module contains a collection of test functions for running acceptance tests on IO::Async::Loop subclasses. It is provided as a
facility for authors of such subclasses to ensure that the code conforms to the Loop API required by "IO::Async".
TIMING
Certain tests require the use of timers or timed delays. Normally these are counted in units of seconds. By setting the environment
variable "TEST_QUICK_TIMERS" to some true value, these timers run 10 times quicker, being measured in units of 0.1 seconds instead. This
value may be useful when running the tests interactively, to avoid them taking too long. The slower timers are preferred on automated
smoke-testing machines, to help guard against false negatives reported simply because of scheduling delays or high system load while
testing.
TEST_QUICK_TIMERS=1 ./Build test
FUNCTIONS
run_tests( $class, @tests )
Runs a test or collection of tests against the loop subclass given. The class being tested is loaded by this function; the containing
script does not need to "require" or "use" it first.
This function runs "Test::More::plan" to output its expected test count; the containing script should not do this.
TEST SUITES
The following test suite names exist, to be passed as a name in the @tests argument to "run_tests":
io
Tests the Loop's ability to watch filehandles for IO readiness
timer
Tests the Loop's ability to handle timer events
signal
Tests the Loop's ability to watch POSIX signals
idle
Tests the Loop's support for idle handlers
child
Tests the Loop's support for watching child processes by PID
control
Tests that the "run", "stop", "loop_once" and "loop_forever" methods behave correctly
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
perl v5.14.2 2012-10-24 IO::Async::LoopTests(3pm)