Sponsored Content
Top Forums Shell Programming and Scripting Processing text variables that have numbers in CShell Post 302570339 by mohy on Thursday 3rd of November 2011 04:57:09 AM
Old 11-03-2011
Processing text variables that have numbers in CShell

Hello,

I have a case where I need to process an environment variable text value in CShell to calculate the product of 2 numbers stated in the variable string having the format "<first_number>Letter x<second_number>".

Ex: $VAR = "24x20"

I need to set $VAR_PRODUCT = "Product of 20 and 24"

Any help would be much appreciated.

Thanks,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed in processing multiple variables in a single sed command.

Is it possible to process multiple variables in a single sed command? I have the following ksh with three variables and I want to search for all variables which start with "var" inside input.txt. I tired "$var$" but it just prints out everyting in input.txt and does not work. $ more test.ksh... (5 Replies)
Discussion started by: stevefox
5 Replies

2. Shell Programming and Scripting

Read text file in Cshell

I've been searching the forums for info on reading a text file in a Cshell script but nothing I'm trying is working. My latest attempt was: set LASInputFile = `ls *. | head -1` echo $LASInputFile while read line do echo $line done < $LASInputFile My error message is: while:... (7 Replies)
Discussion started by: phudgens
7 Replies

3. Shell Programming and Scripting

AWK processing -numbers to another column

Hi Guys, I'm trying to clean up my home logger file and can't seem to work this out. Here is my data: 10-19-2009 08:39 00.2 00.0 00.7 01.1 49.1 0.0 11.9 270.1 -49.1 220.9 10-19-2009 08:40 00.2 00.0 00.7 00.7 49.1 0.0 171.9 171.9 49.1 220.9 10-19-2009 08:41 00.1 00.0 00.7 00.8 24.5 0.0... (2 Replies)
Discussion started by: BeJay
2 Replies

4. Shell Programming and Scripting

[Doubt] How can I store numbers less than 1? Shell variables

Hi everyone, I am having some problems with my scripts so I hope you could help me. I am trying to store the result of a division in a variable in tcshell but I have the problem that if: For example, dividing 2/100 the result is 0.02 but if I store that I have "0". How can I have 0.02... (8 Replies)
Discussion started by: Bloody
8 Replies

5. UNIX for Dummies Questions & Answers

Print numbers and associated text belonging to an interval of numbers

##### (0 Replies)
Discussion started by: lucasvs
0 Replies

6. Shell Programming and Scripting

Using Fractional Numbers in Shell Variables

Hello everyone, Before I state my problem I would like to inform you that this is not an assignment. I'm just trying to learn some shell programming in my free time. I'm trying to write a parking fee calculator. But I don't seem to be able to use fractional numbers. Could you please advice... (6 Replies)
Discussion started by: iwant2learn
6 Replies

7. Shell Programming and Scripting

awk processing of passed variables

Currently have this: set current=192.168.0.5 set servicehost = `echo $current | awk -F. '{print $4}'` echo $numberoffields 5 ..but would like to reduce # of variables and eliminate echo to have something like this: set servicehost = `awk -v s="$current" -F. 'BEGIN{print $2}'`But... (3 Replies)
Discussion started by: Mid Ocean
3 Replies

8. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

9. Shell Programming and Scripting

Help about using variables of float numbers in sed

Hi, I need to run a Fortran program which reads a input file with a fixed name many times, each time I need to change a number (real) in that input file, this is how I currently do it and I know it is not elegent at all: cp inputfile.dat backup.dat sed -i 's/28.0/0.01/g' inputfile.dat ./myCode... (3 Replies)
Discussion started by: dypang
3 Replies

10. UNIX for Beginners Questions & Answers

Comparing multiple variables containing numbers

a=1 456 b=4928 c=23 d=456 I want to compare four variables to get the name of the variable having the highest number (2 Replies)
Discussion started by: proactiveaditya
2 Replies
srchtxt(1)							   User Commands							srchtxt(1)

NAME
srchtxt - display contents of, or search for a text string in, message data bases SYNOPSIS
srchtxt [-s] [-l locale] [-m msgfile ,...] [text] DESCRIPTION
The srchtxt utility is used to display all the text strings in message data bases, or to search for a text string in message data bases (see mkmsgs(1)). These data bases are files in the directory /usr/lib/locale/locale/LC_MESSAGES (see setlocale(3C)), unless a file name given with the -m option contains a /. The directory locale can be viewed as the name of the language in which the text strings are writ- ten. If the -l option is not specified, the files accessed will be determined by the value of the environment variable LC_MESSAGES. If LC_MESSAGES is not set, the files accessed will be determined by the value of the environment variable LANG. If LANG is not set, the files accessed will be in the directory /usr/lib/locale//C/LC_MESSAGES , which contains default strings. If no text argument is present, then all the text strings in the files accessed will be displayed. If the -s option is not specified, the displayed text is prefixed by message sequence numbers. The message sequence numbers are enclosed in angle brackets: <msgfile:msgnum>. msgfile name of the file where the displayed text occurred msgnum sequence number in msgfile where the displayed text occurred This display is in the format used by gettxt(1) and gettxt(3C). OPTIONS
-s Suppress printing of the message sequence numbers of the messages being displayed. -l locale Access files in the directory /usr/lib/locale/locale/LC_MESSAGES. If -m msgfile is also supplied, lOCALE is ignored for msg- files containing a /. -m msgfile Access files specified by one or more msgfiles. If msgfile contains a / character, then msgfile is interpreted as a pathname; otherwise, it will be assumed to be in the directory determined as described above. To specify more than one msgfile, sepa- rate the file names using commas. text Search for the text string specified by text and display each one that matches. text can take the form of a regular expres- sion; see regexp(5). EXAMPLES
Example 1 Using srchtxt If message files have been installed in a locale named french by using mkmsgs(1), then you could display the entire set of text strings in the french locale (/usr/lib/locale/french/LC_MESSAGES/* ) by typing: example% srchtxt -l french Example 2 Using srchtxt If a set of error messages associated with the operating system have been installed in the file UX in the french locale (/usr/lib/locale/french/LC_MESSAGE/UX ), then, using the value of the LANG environment variable to determine the locale to be searched, you could search that file in that locale for all error messages dealing with files by typing: example% setenv LANG=french; export LANG example% srchtxt -m UX "[Ff]ichier" If /usr/lib/locale/french/LC_MESSAGES/UX contained the following strings: Erreur E/S Liste d'arguments trop longue Fichier inexistant Argument invalide Trop de fichiers ouverts Fichier trop long Trop de liens Argument hors du domaine Identificateur supprim Etreinte fatale . . . then the following strings would be displayed: <UX:3>Fichier inexistant <UX:5>Trop de fichiers ouverts <UX:6>Fichier trop long Example 3 Using srchtxt If a set of error messages associated with the operating system have been installed in the file UX and a set of error messages associated with the INGRESS data base product have been installed in the file ingress, both in the german locale, then you could search for the pat- tern [Dd]atei in both the files UX and ingress in the german locale by typing: example% srchtxt -l german -m UX,ingress "[Dd]atei" ENVIRONMENT VARIABLES
See environ(5) for a description of the LC_CTYPE environment variable that affects the execution of srchtxt. FILES
/usr/lib/locale/C/LC_MESSAGES/* default files created by mkmsgs(1) /usr/lib/locale/locale/LC_MESSAGES/* message files created by mkmsgs(1) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------------------------------------+ |ATTRIBUTE TYPE ATTRIBUTE VALUE | |Availability SUNWloc | +-----------------------------------------------------------+ SEE ALSO
exstr(1), gettxt(1), locale(1), mkmsgs(1), gettxt(3C), setlocale(3C), attributes(5), environ(5), locale(5), regexp(5) DIAGNOSTICS
The error messages produced by srchtxt are intended to be self-explanatory. They indicate an error in the command line or errors encoun- tered while searching for a particular locale and/or message file. SunOS 5.11 20 Dec 1996 srchtxt(1)
All times are GMT -4. The time now is 01:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy