write a matrix element, if the "if" condition satisfies
Hi All,
I would like to check a condition in a nxm matrix and if the condition satisfies then, I need to write the matrix element in the output file.
For example, I have a matrix like this:
1 2 3 4 5
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
and i need to test if the difference with the previous column as well as with the first column is more than 2; then I need to write that particular matrix element in the output file.
I tried this:
but filed. Can anyone help me in this regard? your replies are highly appreciated.
But the problem here is, irrespective of the value in the condition, I need to write the matrix element (that means, the row and column number) in the output file. The difference with the first column and the difference with the previous column both should satisfy the conditions. I didn't get your code, why you have started with i=2?
A small modification in my previous code:
The catch here is, I need to write the matrix element not the value at the matrix element, which satisfy the condition?
Thanks elixir sinari, The output should be the number., like [1,2] or [4,5]..etc. It should be the matrix element number.
---------- Post updated at 01:28 PM ---------- Previous update was at 01:18 PM ----------
Thanks elixir sinari, If the difference is more than "1", then I need to write the matrix element (in which row and which column) is satisfying the condition. I tried the following, but getting 0 for all in my output.
[i,j] is the m,n element which is satisfying the condition. your replies are highly appreciated.
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hello,
I am using VirtualBox to simulate a small network with two Linux computers, the host is Mac OS X. My problem is that I can't send "write" and "wall" messages from the host to one of those Linux computers.
Here is what works:
- The virtual Linux computer answers "ping" messages that have... (5 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
I wrote the following script configuring cisco router:#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Opsware::NAS::Connect;
my @IP = split(/\./,"$tc_device_ip$");
my $O3 = $IP;
my($host, $port, $user, $pass) =... (3 Replies)
Hi,
I have defined an array which holds a couple of elements which are nothing but files names. I want to find the files in a directory for the matching file name(array elements) with less than 1 day old.
When I am trying to execute the code (as below), it gives an error.
Your help in this... (1 Reply)
I am attempting to write a awk script that reads in a file after awk array elements are assigned and using those elements while reading in the new file. Does this make sense?
/pattern/ {tst=$3}
(( getline < "file" ) > 0 ) {
x=x " "tst
}
When I print tst in the END statement it... (9 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Hi,
Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I... (6 Replies)