Sponsored Content
Top Forums Shell Programming and Scripting Comparing multiple variable in if statement Post 302634969 by nathan.harris on Friday 4th of May 2012 04:38:13 AM
Old 05-04-2012
Hi there

Thank you for the help on this one, This is the output you requested

Code:
$ pgrep -f "gcalctool"
9467
9486
13903
$ cd /proc
$ ls -ld 9467
dr-xr-xr-x 8 nathan nathan 0 2012-05-04 09:20 9467
$ ls -ld 9486
dr-xr-xr-x 8 nathan nathan 0 2012-05-04 09:20 9486

I also ran the script in ksh and got

Code:
$ ./calc2.sh
./calc2.sh[4]: pushd: not found [No such file or directory]
ls: cannot access 9467: No such file or directory
ls: cannot access 9486: No such file or directory
ls: cannot access 13903: No such file or directory
./calc2.sh: line 13: popd: not found

In the meantime I'll do some digging on those commands there new to me so sorry to appear lazy. Its not clicking just yet...

Smilie

Moderator's Comments:
Mod Comment Please use [code][/code] tags instead of [quote][/quote] tags for code and samples

Last edited by Scrutinizer; 05-04-2012 at 07:06 AM.. Reason: code tags instead of quote tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comparing values of same variable

Hello all while writing a small script , i got stuck with this simple thing.Hope you guyz can help. Iam trying to read password echo"enter password" read $pwd now i have to check this echo"enter password to proceed" read $pwd now i have to check both the values of the... (2 Replies)
Discussion started by: coolkid
2 Replies

2. Shell Programming and Scripting

comparing multiple files in multiple subfolders

Hello, I am having a bit of hard time to get my head around this one. I really hope someone is out there to help me out! Background of my code: I am doing some automation where I am verifying multiple files in multiple sub folders and if they are all identical, I would echo a line with my test... (0 Replies)
Discussion started by: Riz
0 Replies

3. Shell Programming and Scripting

Comparing a variable to a string

Hi, I am trying to write a script to show the status of a Network card. Variables: chosennic is a read variable statuss=`/sbin/ifconfig $chosennic | grep MTU | awk '{print $1}'` ipadd=`/sbin/ifconfig $chosennic | grep Bcast | awk '{print $2}' | awk -F : '{print $2}'`... (2 Replies)
Discussion started by: mikejreading
2 Replies

4. Shell Programming and Scripting

comparing multiple files

hi, quick question i have one file which join one file with reference one Looks like this: KB0000 KB207418 KB0001 KB244904 KB0002 KB215027 KB0003 KB215027 KB0004 KB215027 KB0005 KB204320 KB0006 KB207074 KB0007 KB215204 KB0008 KB223809 KB0009 KB236640 KB0010 KB244506 ....... (2 Replies)
Discussion started by: karla
2 Replies

5. Shell Programming and Scripting

Comparing multiple variables

Hi! I've come up with a ksh-script that produces one or more lists of hosts. At the and of the script, I would like to print only those hosts that exists in all the lists. Ex. HOSTS="host1 host2 host3 host11" HOSTS="host1 host2 host4" HOSTS="host2 host11" HOSTS="host2 host5 host6 host7... (1 Reply)
Discussion started by: Bugenhagen
1 Replies

6. Shell Programming and Scripting

comparing multiple variables by 'if then'

Hi, I am a noob at shell scripting. basically I am trying to compare row counts from 8 tables in different databases. I have managed to get the row counts using awk from the spool files for both databases. now I have 16 variables with me for database 1 : $A $B $C $D $E $F $G... (3 Replies)
Discussion started by: smallville
3 Replies

7. Shell Programming and Scripting

comparing variables in an if statement

#!/bin/bash #timetest TIMENOW="$(date)" T1=12:00:00 echo $TIMENOW >timenow cat timenow |cut -f4 -d' ' >time1 T2=$(sed -n "${1}p" time1) echo "T1 = " $T1 echo "T2 = " $T2 if then echo $T1 else echo $T2 fi I thought scripting was simple! So why does this script result in: T1 =... (4 Replies)
Discussion started by: habuchas
4 Replies

8. UNIX for Advanced & Expert Users

Need help in comparing multiple columns from two files.

Hi all, I have two files as below. I need to compare field 2 of file 1 against field 1 of file 2 and field 5 of file 1 against filed 2 of file 2. If both matches , then create a result file 1 with first file data and if not matches , then create file with first fie data. Please help me in... (12 Replies)
Discussion started by: sivarajb
12 Replies

9. Shell Programming and Scripting

Comparing multiple files

I want to develop one unix script that will first match the multiple files on one server say A with multiple files on another server say B and copy those to server A. After that need to compare the contents of these 2 set of multiple files on different location on same server and generate the... (4 Replies)
Discussion started by: Charnjeet Singh
4 Replies

10. UNIX for Beginners Questions & Answers

How to apply the update statement in multiple servers on multiple dbs at a time .?

Hi , Can any please help the below requirement on all multiple servers and multiple dbs. update configuration set value='yes' ;1) the above statement apply on 31 Databases at a time on different Ip address eg : 10.104.1.12 (unix ip address ) the above ip box contains 4 db's eg : db... (2 Replies)
Discussion started by: venkat918
2 Replies
REF(1)							      General Commands Manual							    REF(1)

NAME
ref - Display a C function header SYNOPSIS
ref [-t] [-c class]... [-f file]... tag DESCRIPTION
ref quickly locates and displays the header of a function. To do this, ref looks in the "tags" file for the line that describes the func- tion, and then scans the source file for the function. When it locates the function, it displays an introductory comment (if there is one), the function's declaration, and the declarations of all arguments. SEARCH METHOD
ref uses a fairly sophisticated tag look-up algorithm. If you supply a filename via -f file, then elvis first scans the tags file for a static tag from that file. This search is limited to the tags file in the current directory. If you supply a classname via -c class, then elvis searches for a tag from that class. This search is not limited to the current direc- tory; You can supply a list of directories in the environment variable TAGPATH, and ref will search through the "tags" file in each direc- tory until it finds a tag in the desired class. If that fails, ref will then try to look up an ordinary global tag. This search checks all of the directories listed in TAGPATH, too. If you've given the -t flag, then ref will simply output the tag line that it found, and then exit. Without -t, though, ref will search for the tag line. It will try to open the source file, which should be in the same directory as the tags file where the tag was discov- ered. If the source file doesn't exist, or is unreadable, then ref will try to open a file called "refs" in that directory. Either way, ref will try to locate the tag, and display whatever it finds. INTERACTION WITH ELVIS
ref is used by elvis' shift-K command. If the cursor is located on a word such as "splat", in the file "foo.c", then elvis will invoke ref with the command "ref -f foo.c splat". If elvis has been compiled with the -DEXTERNAL_TAGS flag, then elvis will use ref to scan the tags files. This is slower than the built-in tag searching, but it allows elvis to access the more sophisticated tag lookup provided by ref. Other than that, external tags should act exactly like internal tags. OPTIONS
-t Output tag info, instead of the function header. -f file The tag might be a static function in file. You can use several -f flags to have ref consider static tags from more than one file. -c class The tag might be a member of class class. You can use several -c flags to have ref consider tags from more than one class. FILES
tags List of function names and their locations, generated by ctags. refs Function headers extracted from source files (optional). ENVIRONMENT
TAGPATH List of directories to be searched. The elements in the list are separated by either semicolons (for MS-DOS, Atari TOS, and Amiga- Dos), or by colons (every other operating system). For each operating system, ref has a built-in default which is probably ade- quate. NOTES
You might want to generate a "tags" file the directory that contains the source code for standard C library on your system. If licensing restrictions prevent you from making the library source readable by everybody, then you can have ctags generate a "refs" file, and make "refs" readable by everybody. If your system doesn't come with the library source code, then perhaps you can produce something workable from the lint libraries. SEE ALSO
elvis(1), ctags(1) AUTHOR
Steve Kirkendall kirkenda@cs.pdx.edu REF(1)
All times are GMT -4. The time now is 05:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy