Sponsored Content
Top Forums Shell Programming and Scripting Shell script to search through numbers and print the output Post 302142774 by aigles on Monday 29th of October 2007 01:55:49 PM
Old 10-29-2007
Try and adapt the following script :
Code:
awk '
NR==FNR {
   from = $1;
   to   = $2;
   for (i=1; i<=3; i++) {
      getline;
      for (j=from; j<=to; j++) {
         Values[j] = (i==1 && j==1 ? "" : Values[j] OFS) substr($0, j-from+1, 1);
      }
   }
   next;
}
{
   if ($1 in Values)
      print $1, Values[$1];
   else
      print $1, "Not Found";
}

' data_file numbers_file

data_file
Code:
1 30
ABCSAAHSNJQJALBALMKAANKAMLAMALK
4562676268836826826868268468368282972982
2863923792102370179372012792701739729291
31 60
HSJBSHSLJSLDINEINSLSLNSLWONSLJWLU
6238286298182720710730723978219021019302
7582687167391937972138892368963883R89942

numbers_file
Code:
1
2
22
30
31
32
44
60
99

Output
Code:
1 A 4 2
2  B 5 8
22  N 8 2
30  L 6 0
31  H 6 7
32  S 2 5
44  N 7 9
60  J 1 6
99 Not Found

Jean-Pierre.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using awk to search and print output

suppose i have one file file A 18 24 30 35 38 45 55 Another file file B 08_46 A 16 V -0.36 0.23 E : 1.41 08_46 A 17 D -1.04 0.22 E : 0.84 08_46 A 18 Q -0.49 0.12 E : 0.06 08_46 A 19 G 0.50 0.14 E : 0.05 08_46 A 20 V ... (5 Replies)
Discussion started by: cdfd123
5 Replies

2. Shell Programming and Scripting

search for the contents in many file and print that file using shell script

hello have a file1 H87I Y788O T347U J23U and file2 J23U U887Y I99U T556U file3 I99O J99T F557J file4 N99I T666U R55Y file5 H87I T347U file6 H77U R556Y E44T file7 Y788O K98U H8I May be using script we can use file1 to search for all the files and have the output H87I file5... (3 Replies)
Discussion started by: cdfd123
3 Replies

3. Shell Programming and Scripting

how can i print the output of the shell script in bigger size

how can i print the output of the shell script in bigger size eg: echo " hello world" i want to print this in the output with bigger size in the middle of the screen. can someone please help me out in that (2 Replies)
Discussion started by: mail2sant
2 Replies

4. Shell Programming and Scripting

search file and print results with shell script

input file 1.<CRMSUB:MSIN=0100004735,BSNBC=TELEPHON-9814060328-TS11&TS21&TS22,NDC=9814,MSCAT=ORDINSUB,SUBRES=ALLPLMN-SPICE,BAOC=OIC,BAPRC=INFO,ACCSUB=BSS,NUMTYP=MULTI;... (3 Replies)
Discussion started by: dodasajan
3 Replies

5. UNIX for Advanced & Expert Users

Shell Script to compare xml files and print output to a file

All, PLease can you help me with a shell script which can compare two xml files and print the difference to a output file. I have attached one such file for you reference. <Group> <Member ID=":Year_Quad:41501" childCount="4" fullPath="PEPSICO Year-Quad-Wk : FOLDER.52 Weeks Ending Dec... (2 Replies)
Discussion started by: kanthrajgowda
2 Replies

6. Shell Programming and Scripting

Shell script to search a pattern in a directory and output number of find counts

I need a Shell script which take two inputs which are 1) main directory where it has to search and 2) pattern to search within main directory all files (.c and .h files) It has to print number of pattern found in main directory & each sub directory. main dir --> Total pattern found = 5 |... (3 Replies)
Discussion started by: vivignesh
3 Replies

7. Shell Programming and Scripting

How to print the output of a select query using shell script?

HI, I want to connect to database and fetch the count from a table. The sql query is as below : select count(*) from table_test where test_column='read'; How can I print the output of this statement using shell script. Thanks in advance. (4 Replies)
Discussion started by: confused_info
4 Replies

8. Shell Programming and Scripting

awk script to search output for a value and print

GOODNUMBERS="1 2 3 4 5 6 3 3 34 34 5 66 12" BADNUMBERS="7 3 12 5 66" for eachnum in `echo ${GOODNUMBERS}` do echo ${BADNUMBERS} | gawk -v threshold=${eachnum} '$1 != threshold' done what im trying to do with the above is, i want to print numbers that are in the GOODNUMBERS... (10 Replies)
Discussion started by: SkySmart
10 Replies

9. Shell Programming and Scripting

Need to Print output in table using shell script

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (4 Replies)
Discussion started by: ankit.mca.aaidu
4 Replies

10. Shell Programming and Scripting

Need shell script to Telnet multiple node , Ping some IP and print output

Hi Team, Need shell script to Telnet multiple node , Ping some IP and print output like pass or fail. Need this script to check reachability of multiple nodes at same time. Help me. I use this but not working... Eg. in this script i need to telnet... (4 Replies)
Discussion started by: Ganesh Mankar
4 Replies
Shell::Perl::Dumper(3pm)				User Contributed Perl Documentation				  Shell::Perl::Dumper(3pm)

NAME
Shell::Perl::Dumper - Dumpers for Shell::Perl SYNOPSYS
use Shell::Perl::Dumper; $dumper = Shell::Perl::Dumper::Plain->new; print $dumper->dump_scalar($scalar); print $dumper->dump_list(@list); DESCRIPTION
In "pirl", the result of the evaluation is transformed into a string to be printed. As this result may be a pretty complex data structure, the shell provides a hook for you to pretty-print these answers just the way you want. By default, "pirl" will try to convert the results via "Data::Dump". That means the output will be Perl code that may be run to get the data structure again. Alternatively, the shell may use "Data::Dumper" or "Data::Dump::Streamer" with almost the same result with respect to the representation as Perl code. (But the output of the modules differ enough for sufficiently complex data.) Other options are to set the output to produce YAML or a plain simple-minded solution which basically turns the result to string via simple interpolation. All of these are implemented via dumper objects. Dumpers are meant to be used like that: $dumper = Some::Dumper::Class->new; # build a dumper $s = $dumper->dump_scalar($scalar); # from scalar to string $s = $dumper->dump_list(@list); # from list to string METHODS The following methods compose the expected API of a dumper, as used by Shell::Perl. new $dumper = $class->new(@args); Constructs a dumper. dump_scalar $s = $dumper->dump_scalar($scalar); Turns a scalar into a string representation. dump_list $s = $dumper->dump_list(@list); Turns a list into a string representation. is_available $ok = $class->is_available This is an optional class method. If it exists, it means that the class has external dependencies (like "Shell::Perl::Data::Dump" depends on "Data::Dump") and whether these may be loaded when needed. If they can, this method returns true. Otherwise, returning false means that a dumper instance of this class probably cannot work. This is typically because the dependency is not installed or cannot be loaded due to an installation problem. This is the algorithm used by Shell::Perl XXX XXX XXX 1. THE STANDARD DUMPERS
Shell::Perl provides four standard dumpers: * Shell::Perl::Data::Dump * Shell::Perl::Data::Dumper * Shell::Perl::Data::Dump::Streamer * Shell::Perl::Dumper::YAML * Shell::Perl::Dumper::Plain which corresponds to the four options of the command " :set out ": "D", "DD", "DDS", "Y", and "P" respectively. Data::Dump The package "Shell::Perl::Data::Dump" implements a dumper which uses Data::Dump to turn Perl variables into a string representation. It is used like this: use Shell::Perl::Dumper; if (!Shell::Perl::Data::Dump->is_available) { die "the dumper cannot be loaded correctly" } $dumper = Shell::Perl::Data::Dump->new; print $dumper->dump_scalar($scalar); print $dumper->dump_list(@list); Examples of its output: pirl > :set out D pirl > { a => 3 } #scalar { a => 3 } pirl > (1, 2, "a") #list (1, 2, "a") Data::Dumper The package "Shell::Perl::Data::Dumper" implements a dumper which uses Data::Dumper to turn Perl variables into a string representation. It is used like this: use Shell::Perl::Dumper; if (!Shell::Perl::Data::Dumper->is_available) { die "the dumper cannot be loaded correctly" } $dumper = Shell::Perl::Data::Dumper->new; print $dumper->dump_scalar($scalar); print $dumper->dump_list(@list); Examples of its output: pirl > :set out DD pirl > { a => 3 } #scalar @var = ( { 'a' => 3 } ); pirl > (1, 2, "a") #list @var = ( 1, 2, 'a' ); YAML The package "Shell::Perl::Dumper::YAML" implements a dumper which uses YAML::Syck or YAML to turn Perl variables into a string representation. It is used like this: use Shell::Perl::Dumper; if (!Shell::Perl::Dumper::YAML->is_available) { die "the dumper cannot be loaded correctly" } $dumper = Shell::Perl::Dumper::YAML->new; print $dumper->dump_scalar($scalar); print $dumper->dump_list(@list); Examples of its output: pirl > :set out Y pirl @> { a => 3 } #scalar --- a: 3 pirl @> (1, 2, "a") #list --- 1 --- 2 --- a When loading, "YAML::Syck" is preferred to "YAML". If it is not avaiable, the "YAML" module is the second option. Data::Dump::Streamer The documentation is yet to be written. Plain Dumper The package "Shell::Perl::Dumper::Plain" implements a dumper which uses string interpolation to turn Perl variables into strings. It is used like this: use Shell::Perl::Dumper; $dumper = Shell::Perl::Dumper::Plain->new; print $dumper->dump_scalar($scalar); print $dumper->dump_list(@list); Examples of its output: pirl > :set out P pirl > { a => 3 } #scalar HASH(0x1094d2c0) pirl > (1, 2, "a") #list 1 2 a SEE ALSO
Shell::Perl BUGS
Please report bugs via CPAN RT <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Shell-Perl> or <mailto://bugs-Shell-Perl@rt.cpan.org>. AUTHORS
Adriano R. Ferreira, <ferreira@cpan.org> Caio Marcelo, <cmarcelo@gmail.com> COPYRIGHT AND LICENSE
Copyright (C) 2007aXX2011 by Adriano R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-03-10 Shell::Perl::Dumper(3pm)
All times are GMT -4. The time now is 09:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy