Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Counting Occurances in Two Files Post 3176 by Keith Gergel on Monday 25th of June 2001 04:03:04 PM
Old 06-25-2001
Question Counting Occurances in Two Files

I have two files I want to compare, one is a list of variables and the other is a text file COBOL program.
Basically what I want to do is display only those variables that appear in the COBOL program only once. However I would also accept a count of each variable as it appears in the COBOL program.

fgrep -f VAR TEST.CBL
will display the lines of the code that match the variable file, however what I need is to locate those variables that have only one match.

Any ideas?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

counting files

Which one line command can count and print to the screen the number of files containing "a" or "A" in their name (5 Replies)
Discussion started by: Edy
5 Replies

2. Shell Programming and Scripting

Help with counting files please

Hi all. If I have a unix directory with multiple files, lets say, I have some with .dat extensions, some with .txt extensions, etc etc. How in a script would I provide a count of all the different file types (so, the different extensions, I guess) in the directory?? So if I had: test.dat... (6 Replies)
Discussion started by: gerard1
6 Replies

3. Solaris

Counting up files

Hi, I have a load of if statements that look for files in a directory, I want to be able to count them up and the total files confirmed in an email? I ahve tried expr but i this does not work and it only reads in the first if and ignores the rest. Please see script, #!/bin/ksh ... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

4. Shell Programming and Scripting

Counting the number of occurances of all characters (a-z) in a string

Hi, I am trying out different scripts in PERL. I want to take a line/string as an input from the user and count the number of occurrances of all the alphabets (a..z) in the string. I tried doingit like this : #! /opt/exp/bin/perl print "Enter a string or line : "; $string = <STDIN>; chop... (5 Replies)
Discussion started by: rsendhilmani
5 Replies

5. Shell Programming and Scripting

multiple files: counting

In a directory, I have 5000 multiple files that contains around 4000 rows with 10 columns in each file containing a unique string 'AT' located at 4th column. OM 3328 O BT 268 5.800 7.500 4.700 0.000 1.400 OM 3329 O BT 723 8.500 8.900... (7 Replies)
Discussion started by: asanjuan
7 Replies

6. Shell Programming and Scripting

Counting Files

In a script, how would I go about finding the number of files for the first parameter after my script name? For instance, my script name is myscript.sh and the folder I am checking is not the current working directory, lets say it's folder1. so I type myscript.sh folder1 This script below... (2 Replies)
Discussion started by: Confirmed104
2 Replies

7. UNIX for Dummies Questions & Answers

Counting files without ls or wc

i need to write a shell script to "count the number of files in the current directory but without using either ls or wc command"..... please help! (1 Reply)
Discussion started by: lexicon
1 Replies

8. Shell Programming and Scripting

Count the number of occurances for multiple files

I have some text files as shown below. I would like to add the values of each string. Your help would be appreciated!! file1.txt SUS 2 PRS 2 ALI 1 PRS 1 GLK 2 file2.txt PRS 3 GLK 6 SUS 18 Desired output SUS 20 PRS 6 (2 Replies)
Discussion started by: arch
2 Replies

9. Shell Programming and Scripting

2 files replace multiple occurances based on a match

Hi All, I need some help trying to achieve the below but everything I've tried has failed, I have 2 files which i'm trying to carry out a match based on the first column from file 1, take that value find it in file 2 if found replace it with the second column from File 1 Lookup File: File 1... (3 Replies)
Discussion started by: mutley2202
3 Replies
GAMMU-SMSD-RUN(7)						       Gammu							 GAMMU-SMSD-RUN(7)

NAME
gammu-smsd-run - documentation for RunOnReceive directive DESCRIPTION
Gammu SMSD can be configured by RunOnReceive directive (see gammu-smsdrc for details) to run defined program after receiving every message. It can receive single message or more messages, which are parts of one multipart message. This parameter is executed through shell, so you might need to escape some special characters and you can include any number of parameters. Additionally parameters with identifiers of received messages are appended to the command line. The identifiers depend on used service backend, typically it is ID of inserted row for database backends or file name for file based backends. Gammu SMSD waits for the script to terminate. If you make some time consuming there, it will make SMSD not receive new messages. However to limit breakage from this situation, the waiting time is limited to two minutes. After this time SMSD will continue in normal operation and might execute your script again. Note All input and output file descriptors are closed when this program is invoked, so you have to ensure to open files on your own. ENVIRONMENT
program is executed with environment which contains lot of information about the message. You can use it together with NULL service (see gammu-smsd-null) to implement completely own processing of messages. Global variables SMS_MESSAGES Number of physical messages received. DECODED_PARTS Number of decoded message parts. Per message variables The variables further described as SMS_1_... are generated for each physical message, where 1 is replaced by current number of message. SMS_1_CLASS Class of message. SMS_1_NUMBER Sender number. SMS_1_TEXT Message text. Text is not available for 8-bit binary messages. Per part variables The variables further described as DECODED_1_... are generated for each message part, where 1 is replaced by current number of part. Set are only those variables whose content is present in the message. DECODED_1_TEXT Decoded long message text. DECODED_1_MMS_SENDER Sender of MMS indication message. DECODED_1_MMS_TITLE title of MMS indication message. DECODED_1_MMS_ADDRESS Address (URL) of MMS from MMS indication message. DECODED_1_MMS_SIZE Size of MMS as specified in MMS indication message. EXAMPLES
Activating RunOnReceive To activate this feature you need to set RunOnReceive in the gammu-smsdrc. [smsd] RunOnReceive = /path/to/script.sh Processing messages from the files backend Following script (if used as RunOnReceive handler) passes message data to other program. This works only with the gammu-smsd-files. #!/bin/sh INBOX=/path/to/smsd/inbox PROGRAM=/bin/cat for ID in "$@" ; do $PROGRAM < $INBOX/$ID done Passing message text to program Following script (if used as RunOnReceive handler) passes message text and sender to external program. #!/bin/sh PROGRAM=/bin/echo for i in `seq $SMS_MESSAGES` ; do eval "$PROGRAM "${SMS_${i}_NUMBER}" "${SMS_${i}_TEXT}"" done Passing MMS indication parameters to external program Following script (if used as RunOnReceive handler) will write information about each received MMS indication to the log file. Just replace echo command with your own program to do custom processing. #!/bin/sh if [ $DECODED_PARTS -eq 0 ] ; then # No decoded parts, nothing to process exit fi if [ "$DECODED_1_MMS_ADDRESS" ] ; then echo "$DECODED_1_MMS_ADDRESS" "$DECODED_1_MMS_SENDER" "$DECODED_1_MMS_TITLE" >> /tmp/smsd-mms.log fi Processing message text in Python Following script (if used as RunOnReceive handler) written in Python will concatenate all text from received message: #!/usr/bin/python import os import sys numparts = int(os.environ['DECODED_PARTS']) # Are there any decoded parts? if numparts == 0: print('No decoded parts!') sys.exit(1) # Get all text parts text = '' for i in range(1, numparts + 1): varname = 'DECODED_%d_TEXT' % i if varname in os.environ: text = text + os.environ[varname] # Do something with the text print('Number %s have sent text: %s' % (os.environ['SMS_1_NUMBER'], text)) AUTHOR
Michal iha <michal@cihar.com> COPYRIGHT
2009-2012, Michal iha <michal@cihar.com> 1.31.90 February 24, 2012 GAMMU-SMSD-RUN(7)
All times are GMT -4. The time now is 10:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy