Sponsored Content
Full Discussion: Tricky Shell script
Top Forums Shell Programming and Scripting Tricky Shell script Post 302133342 by fazliturk on Thursday 23rd of August 2007 03:59:22 AM
Old 08-23-2007
Quote:
Originally Posted by namishtiwari
lorcan,
thanks for the input.

when i ran the script it is telling

./testingscript testingdata
Check the 1 field of the INPUT FILE

it is not incrementing the COUNT value so it is printing only a single record at a time.

You mentioned ---
This script checks for the 15 tickets in a row and also checks if there are 5 tickets within every 9 columns.

And as a whole i am checking whether there are atleast one ticket in a column and arranged in ascending order.

The first one you mentioned is perfectly fine.

the second line is somewhat like this--
00,11,21,00,00,55,00,73,83,07,00,22,39,43,00,66,00,00,00,15,00,00,44,58,67,00,87

this is one data in a file,it consists of 3 rows and 9 columns.we can break
00,11,21,00,00,55,00,73,83
07,00,22,39,43,00,66,00,00
00,15,00,00,44,58,67,00,87

We need to check in this that each column should have min 1 value and if more than that then it should be in ascending order not as a whole.

Thanks for your kind help.
/* Error messages ;
“COL”i”FNW”=Column numberx Total Field amount less than 1 or more than 2
“COL””i”NA” =Column numberx Not ascending
“RW1NA”=Row1 not ascending
“R1FN5 " = Row1 Total field amount is less or more than 5
*/
/*NR is line number of inputfile */

Try this code ;

cat inputfile | awk -F',' '{
last1=0;last2=0;last3=0;i=0;k=0;l=0;m=0;msg="";r1=0;r2=0;r3=0;
while ( i < 9 )
{
i++;n=0;
if ( $i != 0 )
{
n++;k++;
if ( $i > last1 ) {last1=$i}else { r1=1}};

if ( $(i+9) != 0 )
{
n++;l++;
if ( $(i+9) > last2 ) {last2=$(i+9)}else { r2=1 }};

if ( $(i+18) != 0 )
{
n++;m++;
if ( $(i+18) > last3 ) {last3=$(i+18)}else { r3=1 }};

if ( n < 1 )
{ msg=msg"COL"i"FNW " }
else
{
if (( $i != 0 ) && ( $(i+9) != 0 ) && ( $(i+9) < $i )){msg=msg"COL"i"NA "}
else {
if (( $i != 0 ) && ( $(i+18) != 0 ) && ( $(i+18) < $i )){msg=msg"COL"i"NA "}
else {
if (( $(i+9) != 0 ) && ( $(i+18) != 0 ) && ( $(i+18) < $(i+9) )){msg=msg"COL"i
"NA " }
else {
if ((( $i != 0 ) && ( $(i+9) != 0 ) && ( $(i+18) != 0 )) && ( ( $i > $(i+9) )
|| ( $i > $(i+18) ) || ( $(i+9) > $ (i+18) ) )) { msg=msg"COL"i"NA " } ;}}}}};

if ( r1 != 0 ) {msg=msg"RW1NA "};
if ( r2 != 0 ) {msg=msg"RW2NA "};
if ( r3 != 0 ) {msg=msg"RW3NA "};
if ( k != 5 ) {msg=msg"R1FN5 "};
if ( l != 5 ) {msg=msg"R2FN5 "};
if ( m != 5 ) {msg=msg"R3FN5 "};
if ( msg != "" ) {printf ( "%d " "%s" "\n",NR,msg)};
}'
 

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Tricky one...

Here's my problem: I have a laptop running Windows XP Pro with no internal CD or Floppy drives. I want to install Linux on it. I don't care about the Windows XP Pro installation, in fact I would like to install Linux over the entirety of the HD. However I cannot boot from any external CD drive... (1 Reply)
Discussion started by: saabir
1 Replies

2. Shell Programming and Scripting

Tricky Sed

Hello. I am trying to convert occurrences of 'NULL' from a datafile. The 'NULL' occurences appears at this: |NULL| NULL|NULL| NULL|NULL| NULL|NULL| NULL| There should be 52 fields per line. I would like any occurrence of | NULL| or |NULL| to appear as '||' Currently I am using this sed... (2 Replies)
Discussion started by: bestbuyernc
2 Replies

3. Shell Programming and Scripting

Tricky script question

Hi, I'm in the midst of writing a UNIX script that sftp's files to an external host and am stuck with a problem. The problem is that the files created on my server as a order number that correlates to a sequence of directories on the remote host which is where the file should be ftp'ed. ... (3 Replies)
Discussion started by: budrito
3 Replies

4. UNIX for Dummies Questions & Answers

Tricky Quotation Question

Hi, I am at a point in my script where I defined the number of the command line parameter I would like to set a variable equal to: parameter_number=14 I would then like to set a variable equal to the correct parameter: variable=$parameter_number The issue here is that {} is required... (2 Replies)
Discussion started by: msb65
2 Replies

5. Shell Programming and Scripting

Linux: Writing a tricky script to check connectivity

So, first and foremost, I'm having issues with my internet connection. Periodically, the connection drops across the network. The fix is simple enough: restart the modem. However, this gets old when the connection dies out every hour. I can hit my surfboard on 192.168.100.1, and navigate to a... (5 Replies)
Discussion started by: kungfujoe
5 Replies

6. Shell Programming and Scripting

Tricky - Need help on Shell script variables

Hi, I have a requirement in which i have to read a csv file and put data in certain set of variables: File content: VP-DTL-REC-CNT, ,854840,0.00,VP-PAID-AMT, ,0,32280885.17,VP-PAT-PAID-AMT, ,0,9930244.32,VP-PAID-REV-CNT, ,484927,0.00,VP-REJ-CNT, ,369913,0.00, , ,0,0.00, , ,0,0.00, , ,0,0.00, ,... (3 Replies)
Discussion started by: shantoshkumar
3 Replies

7. Shell Programming and Scripting

Tricky data manipulation...

Hi everyone.. I am new here, hello.. I hope this doesn't come across to you folks as a stupid question, I'm somewhat new to scripting :) I'm seeking some help in finding a way to manipulate data output for every two characters - example: numbers.lst contains the following output:... (3 Replies)
Discussion started by: explicit
3 Replies

8. Solaris

Tricky egrep

Hi folks! My first post here. I'm working on a script that retrieves a range of files from a list depending on a range of time. UPDATE: I've seen it could be difficult to read all this thing, so I'll make a summarize it.. How come I do this and take a result.. grep "..\:.." lista.new |... (4 Replies)
Discussion started by: kl0x
4 Replies

9. Shell Programming and Scripting

Tricky sed required

Hi All I need to put some sed together for a task and its a bit advanced for me, so I thought I'd ask if anyone here could help. I have a csv file with content like this - "","abcde","","" "'","abcde","","" "","","","1234" "'e'","","","" I need to remove any single quotes that fall... (17 Replies)
Discussion started by: steadyonabix
17 Replies

10. Shell Programming and Scripting

Parsing xml - tricky one...need help!!

Hi, i am new to linux programming fraternity but looks like starting with a big thing... yes..xml parsing (it is indeed tough for a beginner like me) so need your kind help... The snippet of xml looks like: <snapshot> <tag1> <key>1234</key> <keytype>abcd</keytype> </tag1> <tag2>... (11 Replies)
Discussion started by: rookie2014
11 Replies
gui_shadow_box_proc(3alleg4)					  Allegro manual				      gui_shadow_box_proc(3alleg4)

NAME
gui_shadow_box_proc, gui_ctext_proc, gui_button_proc, gui_edit_proc, gui_list_proc, gui_text_list_proc - Hooks to customise the look and feel of Allegro dialogs. SYNOPSIS
#include <allegro.h> extern int (*gui_shadow_box_proc)(int msg, struct DIALOG *d, int c); extern int (*gui_ctext_proc)(int msg, struct DIALOG *d, int c); extern int (*gui_button_proc)(int msg, struct DIALOG *d, int c); extern int (*gui_edit_proc)(int msg, struct DIALOG *d, int c); extern int (*gui_list_proc)(int msg, struct DIALOG *d, int c); extern int (*gui_text_list_proc)(int msg, struct DIALOG *d, int c); DESCRIPTION
If set, these functions will be used by the standard Allegro dialogs. This allows you to customise the look and feel, much like gui_fg_color and gui_bg_color, but much more flexibly. SEE ALSO
alert(3alleg4), alert3(3alleg4), file_select_ex(3alleg4), gfx_mode_select(3alleg4), gui_fg_color(3alleg4) Allegro version 4.4.2 gui_shadow_box_proc(3alleg4)
All times are GMT -4. The time now is 07:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy