I need to assign a variable within a variable in a sed command.
I tried doing the following in c shell.
set left = 1
set right = 2
set segment = qwerty
sed -n -e "/$segment{$left}/,/$segment{$right}/p" file.txt
what is wrong with this syntax? (3 Replies)
If I have 3 variables and I want to check if any of these is null. If one of them is null then it should be assigned a value of 0.I have the following code below.
The output should be 0 is A, 11 is B, 33 is C
$a=
$b=11
$c=33
$echo $a $b $c
$11 33
for i in "${a}" "${b}" "${c}";
do
... (2 Replies)
Hi All,
While executing following for loop in unix, it is working fine.
sum=0
tot_amt=`for i in `cat amt`
do
sum=`echo "$sum + $i"|bc`
done`
But if i assing this loop in a variable it is not working. The error is so and done is unexpected.
tot_val=`sum=0;tot_amt=`for i in... (3 Replies)
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)
Hi Forum,
I am struggling with the for loop in shell script.
Let me explain what is needed in the script.
I have a file which will conatin some strings like
file1
place1
place2
place3
checkpoint
some other text
some more text
Now what my requirement is
the words ... (2 Replies)
Hi
I am new to shell scripting and i am preparing a script.
for now i am work on a sub part of it..but i am unable to make it work.
---
the test code that i am working on
--------------------------
IFS=""
Sample_eve=`psg proc_s | grep tY`
n=0
for line in $Sample_eve... (41 Replies)
Hi ,
i am using below code print the PATH value inside for loop but it's printing just PATHD & not the original value which i defined.
#!/usr/bin/bash
PATHD1=/spp/sp/LIVE
export PATHD1
PATHD2=/spp/sp/TEST
export PATHD2
j=2
for (( i = 1 ; i <= j ; i++ ))
do
PATH_DIR=PATH$i
echo PATHD$i... (2 Replies)
Please help me to automatically assign the output of awk command to the variables cs3, cs4, cs5 and cs6 using a for loop. The below code is not working.
for i in 3 4 5 6
do
cs$i=`awk -F"|" 'BEGIN{sum=0}{sum=sum+$'$i'}END{printf("%d\n", sum)}' css`
done
echo $cs3 $cs4 $cs5 $cs6 (9 Replies)
Hi, I was wondering if anyone could assist me for (what is probably) a very straightforward answer.
I have input files containing something like
File 1
Apples
Apples
Apples
Apples
File 2
Bananas
Bananas
Bananas
Bananas (4 Replies)
Hi All,
Is it possible to grep for two files and assign their names to two separate variables with for loop? I am doing the below currently:
if
then
for fname in $( cd $dirA ; ls -tr | grep "^Ucountry_file$")
do
InFile=$dirA/$fname
... (4 Replies)
Discussion started by: swasid
4 Replies
LEARN ABOUT DEBIAN
io::async::protocol::linestream
IO::Async::Protocol::LineStream(3pm) User Contributed Perl Documentation IO::Async::Protocol::LineStream(3pm)NAME
"IO::Async::Protocol::LineStream" - stream-based protocols using lines of text
SYNOPSIS
Most likely this class will be subclassed to implement a particular network protocol.
package Net::Async::HelloWorld;
use strict;
use warnings;
use base qw( IO::Async::Protocol::LineStream );
sub on_read_line
{
my $self = shift;
my ( $line ) = @_;
if( $line =~ m/^HELLO (.*)/ ) {
my $name = $1;
$self->invoke_event( on_hello => $name );
}
}
sub send_hello
{
my $self = shift;
my ( $name ) = @_;
$self->write_line( "HELLO $name" );
}
This small example elides such details as error handling, which a real protocol implementation would be likely to contain.
DESCRIPTION EVENTS
The following events are invoked, either using subclass methods or CODE references in parameters:
on_read_line $line
Invoked when a new complete line of input is received.
PARAMETERS
The following named parameters may be passed to "new" or "configure":
on_read_line => CODE
CODE reference for the "on_read_line" event.
METHODS
$lineprotocol->write_line( $text )
Writes a line of text to the transport stream. The text will have the end-of-line marker appended to it; $text should not end with it.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
perl v5.14.2 2012-10-24 IO::Async::Protocol::LineStream(3pm)