Sponsored Content
Top Forums Shell Programming and Scripting Need help with pattern matching to list missing packages Post 302968362 by jim mcnamara on Tuesday 8th of March 2016 05:28:42 PM
Old 03-08-2016
Code snipped:
Code:
if yum list installed $PACKAGE >/dev/null 2>&1;
then
  echo "$PACKAGE is installed"
else
  echo "$PACKAGE not installed"
  exit 1
fi

The exit 1 statement causes the loop and the script both to terminate. Also the return code will be a failure. Is this what you meant?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

2. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

3. Shell Programming and Scripting

sed - matching pattern one but not pattern two

All, I have the following file: -------------------------------------- # # /etc/pam.d/common-password - password-related modules common to all services # # This file is included from other service-specific PAM config files, # and should contain a list of modules that define the services... (2 Replies)
Discussion started by: RobertBerrie
2 Replies

4. UNIX for Dummies Questions & Answers

Script to list non matching files using pattern

Hi, I am trying to write a script that list down all the files that do not match the pattern My pattern will be like this "*.jpg|*.xml|*.sql". This pattern will be stored in a file. The script need to read this pattern from the file and delete the files that does not match this pattern. It... (7 Replies)
Discussion started by: meenavin
7 Replies

5. Shell Programming and Scripting

How to cut string and find missing pattern?

i have list in file named sample.txt eg i want to cut the 3rd and 4th character i.e. 01,02,03....,24(max length is 24) and i want to find the missing sequence .and display them i.e. (15 Replies)
Discussion started by: sagar_1986
15 Replies

6. UNIX for Dummies Questions & Answers

Find pattern suffix matching pattern

Hi, I am trying to get a result out of this but fails please help. Have two files /tmp/1 & /tmp/hosts. /tmp/1 IP=123.456.789.01 WAS_HOSTNAME=abcdefgh.was.tb.dsdc /tmp/hosts 123.456.789.01 I want this result in /tmp/hosts if hostname is already there dont want duplicate entry. ... (5 Replies)
Discussion started by: rajeshwebspere
5 Replies

7. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

8. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

9. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

10. Shell Programming and Scripting

awk Matching Columns - Am I missing something?

I am using awk to match columns and output based on those matches. For some reason it is not printing matching columns, am I missing something? Operating system - windows with cygwin. Command that I am using: sed 's/]*,]*/,/g' $tempdir/file1 > $tempdir/file1.$$ && awk -F, 'FNR==NR{f2=$2... (7 Replies)
Discussion started by: dis0wned
7 Replies
APT-SHOW-VERSIONS(1p)					User Contributed Perl Documentation				     APT-SHOW-VERSIONS(1p)

NAME
apt-show-versions - Lists available package versions with distribution DESCRIPTION
apt-show-versions parses the dpkg status file and the APT lists for the installed and available package versions and distribution and shows upgrade options within the specific distribution of the selected package. This is really useful if you have a mixed stable/testing environment and want to list all packages which are from testing and can be upgraded in testing. apt-show-versions uses caching for the status information of installed and available packages. If you run apt-show-versions as root the cache is updated as needed. If you run as non-root uses the newest available information, but can't update the cache. If you run as root with the option -i the cache is initialized or updated only. SYNOPSIS
apt-show-versions [-h] [[-p] package name] [-a] [-b] OPTIONS
If you don't give any options the status of all installed packages is printed. -p package, --package=package Print available and installed versions for specified package. You can also specify a package name without the option -p. If -p and a package name are missing, all installed packages are displayed. -r, --regex interpret package from option -p as a regex. -R, --regex-all like --regex, but also show matching packages which are not installed -u, --upgradeable Print only upgradeable packages -a, --allversions Print all available versions of the selected packages -b, --brief Print only package_name/distribution for upgradeable packages -v, --verbose Prints out messages about which Package files are parsed. -i, --initialize Initialize or update package cache only (as root). Do this every time when the status of the installed or available packages has changed. Initialization is done automatically on installation of the package and via a cron.daily job. -stf file, --status-file=file Use file as the dpkg status file instead of /var/lib/dpkg/status -ld directory, --list-dir=directory Use directory as path to apt's list files instead of /var/state/apt/lists/ or /var/lib/apt/lists/ -h, --help Prints out command-line help. EXIT CODES
0 No error 1 Wrong usage 2 apt-show-versions has been called with exactly one package and upgradeable option set, but package is uptodate. As no output has been requested, this case gets signaled using the exit code. 255 Unspecified error EXAMPLES
If you want to know for all your installed packages whether they are uptodate or upgradeable, use: apt-show-versions If you want to have a list of all upgradeable packages: apt-show-versions -u To get a list of all available versions of libc6: apt-show-versions -a -p libc6 To get information about several packages: apt-show-versions dpkg apt apt-show-versions -r ^texlive To upgrade all packages in testing: apt-get install `apt-show-versions -u -b | fgrep testing` AUTHOR
Christoph Martin, martin@uni-mainz.de SEE ALSO
apt(8), dpkg(1) perl v5.14.2 2012-10-26 APT-SHOW-VERSIONS(1p)
All times are GMT -4. The time now is 09:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy