Sponsored Content
Top Forums Shell Programming and Scripting need help simplifying an if statement Post 302570207 by Corona688 on Wednesday 2nd of November 2011 04:16:59 PM
Old 11-02-2011
Slight modification to that:

Code:
if grep -q "^$ver\$" filename
then
        echo "Matches"
else
        echo "Doesn't match"
fi

This will prevent partial matches from happening, it will match only whole lines.

Unfortunately . is a special character to grep, so it's possible 4.02.011 could still match against 4302911.
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in simplifying a sed command

I need to do a substitution: CPF to ,C,P,F, CPM to ,C,P,M, SPF to ,S,P,F etc. I can do each of them with separate substitutions e.g. s/CPF/,C,P,F/ but I'd like to know if there is a more elegant solution. In general, how can I use the results of the search in the substitution, ... (3 Replies)
Discussion started by: wvdeijk
3 Replies

2. Shell Programming and Scripting

Simplifying the For loop

Is there a way to simplify stating 1 through to 10, for example in a for loop construct? for x in 1 2 3 4 5 6 7 8 9 10 do .... done I have tried (1-10) with no luck.. thanks (2 Replies)
Discussion started by: sirtrancealot
2 Replies

3. Shell Programming and Scripting

simplifying awk

tcpdump -nr testdump|awk '!/:/;gsub(/^+|+$/,""){print $3};a!~$0;{a=$0};{print $3};!/length/;/./;!/11\:/;!/8 7 6 5 4 3 2 1/;!/UDP/{b=$0} END {for (j=i-1; j>=0; ) print b };{for (i=NF; i>0; i--) printf("%s ",i);printf ("\n")}' *NOTE IN j>=0 the ; ) was given a space since a smiley is showing up...... (1 Reply)
Discussion started by: sil
1 Replies

4. UNIX for Advanced & Expert Users

Simplifying my script

Hi, Is there a way to simplify the below script? Because I am having problems executing this if I added this to CRON. Also, you may notice that its objective is to put all information in one file (rm1.txt). And in addition file "sRMR_6.txt" to sRMR_23.txt" changes its information everyday.... (4 Replies)
Discussion started by: vibora
4 Replies

5. Shell Programming and Scripting

Simplifying IPv6 addresses from user input

hi friends, im new to scripting and am tiring out to valid an ip address if user inputs 9 : 003 : 0 : 0 : 100 : 256 ,i need to suppress all leading zeros and single zero ie out put for the same should be 9 : 3 : : : 100 : 256 can any help using awk ,regular expression to split the string... (1 Reply)
Discussion started by: sandeepjeede
1 Replies

6. Shell Programming and Scripting

Simplifying sed/tr

Hi all, I don't have much experience with shell scripting and I was wondering if there's a shorter way to write this. Basically, given a list of strings separated by new lines, I want to prepend each string with a prefix and separate the strings with commas i.e. stra strb strc becomes... (3 Replies)
Discussion started by: vshan
3 Replies

7. UNIX for Beginners Questions & Answers

Simplifying awk/sed short pipeline

I have a file like this: FileName,Well,Sample Description,Size ,Calibrated Conc. ,Assigned Conc. ,Peak Molarity ,Area,% Integrated Area,Peak Comment,Observations 2017-11-15 - 13.49.50.D1000,EL1,Electronic Ladder,25,5.22,,321,0.803,,,Lower Marker 2017-11-15 - 13.49.50.D1000,EL1,Electronic... (6 Replies)
Discussion started by: Xterra
6 Replies
gd_alter_protection(3)						      GETDATA						    gd_alter_protection(3)

NAME
gd_alter_protection -- modify the protection level of a dirfile fragment SYNOPSIS
#include <getdata.h> int gd_alter_protection(DIRFILE *dirfile, int protection_level, int fragment_index); DESCRIPTION
The gd_alter_protection() function sets the advisory protection level of the format specification fragment given by fragment_index to pro- tection_level in the dirfile(5) database specified by dirfile. The protection_level argument should be one of the following: GD_PROTECT_NONE Indicating that the fragment should not be protected at all. GD_PROTECT_FORMAT Indicating that the fragment's metadata should be protected. GD_PROTECT_DATA Indicating that the fragment's binary data should be protected. GD_PROTECT_ALL Indicating that both the fragment's metadata and its binary data should be protected. This symbol is equivalent to the bitwise or of GD_PROTECT_FORMAT and GD_PROTECT_DATA. In addition to being simply a valid fragment index, fragment_index may also be the special value GD_ALL_FRAGMENTS, which indicates that the protection level of all fragments in the database should be changed. RETURN VALUE
Upon successful completion, gd_alter_protection() returns zero. On error, it returns -1 and sets the dirfile error to a non-zero error value. Possible error values are: GD_E_ACCMODE The specified dirfile was opened read-only. GD_E_BAD_DIRFILE The supplied dirfile was invalid. GD_E_BAD_INDEX The supplied index was out of range. GD_E_BAD_PROTECTION The supplied protection level was invalid. The dirfile error may be retrieved by calling gd_error(3). A descriptive error string for the last error encountered can be obtained from a call to gd_error_string(3). NOTES
This is the only GetData function which ignores the (existing) protection level of a format specification fragment. SEE ALSO
gd_open(3), gd_error(3), gd_error_string(3), gd_protection(3), dirfile(5), dirfile-format(5) Version 0.7.0 21 July 2010 gd_alter_protection(3)
All times are GMT -4. The time now is 09:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy