Sponsored Content
Top Forums Shell Programming and Scripting Searching word in a file with awk Post 302213160 by studieu on Wednesday 9th of July 2008 10:58:04 AM
Old 07-09-2008
Searching word in a file with awk

Hello everyone!

I use a script to query for installed packages with yum (I use RHEL 4 with yum installed) and the output is redirected to a file. My script scan this file to find a package and the version of it.

The script works fine until I search for a package name with special characters. So if I search for gcc.x86_64 I get all the info I need but if I search for gcc-c++.x86_64. I don't get anything.

My search string looks like this :
Code:
version=$(awk '/^gcc.x86_64/ { print $2}' /tmp/yum_output.txt)

The ouput of yum is :
Code:
Setting up repositories
Reading repository metadata in from local files
Installed Packages
gcc.x86_64                               3.4.6-3                installed


So if I echo version, I get this :
Code:
# version=$(awk '/^gcc.x86_64/ { print $2}' /tmp/yum_output.txt)
# echo $version
3.4.6-3
#

When I do the same thing with gcc-c++.x86_64, I get nothing if I echo version.
Code:
# version=$(awk '/^gcc-c++.x86_64/ { print $2}' /tmp/yum_output.txt)
# echo $version

#


Is there any way I can get this to work?

Last edited by radoulov; 07-09-2008 at 12:23 PM.. Reason: please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Searching for key word within a file

Hello, I have a directory that holds all of my matlab codes. I am trying to run a searh on all of the matlab files that have the word "while" written inside the sytax of the code. Looking for all of the times that I did a while loop. Can someone help me do this? Thanks in advance. ... (1 Reply)
Discussion started by: moradwan
1 Replies

2. UNIX for Dummies Questions & Answers

searching word in files

hi all i want to search some word in file but i want that it will search in all the files that i have in all the directories i do'nt know the name of the file i know that grep command want some specified file in which command shell i used thanks (2 Replies)
Discussion started by: naamas03
2 Replies

3. Shell Programming and Scripting

problem while searching in a file by 'AWK'

Hi , i am writing a script in which i am using following command to grep some string and then storing it's output to v, as like below :- v=$(awk -F, '{ if ( $NF ~ /DEV/ ) print $0 "_BLD01";else print $0 "_RC01" }' mytest) Here i am facing following issues:- 1. it is searcing DEV in the... (1 Reply)
Discussion started by: inderpunj
1 Replies

4. Shell Programming and Scripting

Reading an Input file and searching for occurrences WIHOUT SED or AWK

Hi people. I am new to shell scripting, so I need a little help. I want to create a script named that takes an argument as a file, Read the input file and look for occurrences of the current username (say abc.xyz) who is executing the script. On finding an occurrence of the username take that line... (2 Replies)
Discussion started by: kartikkumar84@g
2 Replies

5. UNIX for Dummies Questions & Answers

Searching mutiple word - Tuning grep command

Hi all, I have a log file which is more than 1GB, i need to take count from the log file for two strings. i am using the below command but it take a long time to excetue, i need to tune this. Please help me cat /logs/gcbs/gcbsTrace.log | grep -i "ViewStatementBusinessLogic" | grep -c -i... (8 Replies)
Discussion started by: senthilkumar_ak
8 Replies

6. Shell Programming and Scripting

searching in a while where a word is not there.

Hi, I am new to unix, pls help I have a file suc_Logfile file. liek this. output success success abc Now i need to generate a file in shell script where it shows only abc. Now i am doing like this grep "^successfully\|$" $suc_Logfile >> $Final_Suc Pls help. Thanks,... (6 Replies)
Discussion started by: sailaja_80
6 Replies

7. Shell Programming and Scripting

Insert tags in lines after searching for a word

Hi, I am new to Unix and this is my first post on this forum. I am trying to convert a file into an xml. In my input I want to search for any line that starts with a 'F' and make it a tag in the xml. See below for the input and output. Input : <Payment> <REFERENCE>78</REFERENCE> F123 : ... (7 Replies)
Discussion started by: akashgov
7 Replies

8. Shell Programming and Scripting

Searching a word in multiple files

Hi All, I have a issue in pulling some heavy records , I have my input file has 10,000 records which i need to compare with daily appended log files from (sep 1st 2009 to till date) . I tried to use grep fgrep and even sed , but the as time is factor for me , i cannot wait for 5 days to get the... (3 Replies)
Discussion started by: rakesh_411
3 Replies

9. Shell Programming and Scripting

Searching a file using awk or sed

I want to search a file in a specific location and I don't want to use find command. I want to give the path also where the file is for searching it. Pls help (3 Replies)
Discussion started by: maitree
3 Replies

10. Shell Programming and Scripting

Problem with the awk in searching the contents in a file

Hello all, I am a newbie in awk. I am struggling in this problem for a long.Actually I have two files, filea and fileb. File a is actually a search key through it I have to find the corresponding japanese tag from file b. filea contains the data like this: sm982882 sm1893548 sm2420025... (3 Replies)
Discussion started by: csim_mohan
3 Replies
reposync(1)															       reposync(1)

NAME
reposync - synchronize yum repositories to a local directory SYNOPSIS
reposync [options] DESCRIPTION
reposync is used to synchronize a remote yum repository to a local directory, using yum to retrieve the packages. OPTIONS
-h, --help Display a help message, and then quit. -c CONFIG, --config=CONFIG Config file to use (defaults to /etc/yum.conf). -a ARCH, --arch=ARCH Act as if running the specified arch (default: current arch, note: does not override $releasever. x86_64 is a superset for i*86.). --source Also download .src.rpm files. -r REPOID, --repoid=REPOID Specify repo ids to query, can be specified multiple times (default is all enabled). -t, --tempcache Use a temp dir for storing/accessing yum-cache. -p DESTDIR, --download_path=DESTDIR Path to download packages to: defaults to current directory. -g, --gpgcheck Remove packages that fail GPG signature checking after downloading. exit status is '1' if at least one package was removed. -u, --urls Just list urls of what would be downloaded, don't download. -l, --plugins Enable yum plugin support. -n, --newest-only Download only newest packages per-repo. -q, --quiet Output as little information as possible. EXAMPLES
Sync all packages from the 'updates' repo to the current directory: reposync --repoid=updates Sync only the newest packages from the 'updates' repo to the current directory: reposync -n --repoid=updates Sync packages from the 'updates' and 'extras' repos to the current directory: reposync --repoid=updates --repoid=extras Sync all packages from the 'updates' repo to the repos directory: reposync -p repos --repoid=updates Sync all packages from the 'updates' repo to the repos directory excluding x86_64 arch. Edit /etc/yum.conf adding option exclude=*.x86_64. Then: reposync -p repos --repoid=updates FILES
reposync uses the yum libraries for retrieving information and packages. If no configuration file is specified, the default yum configura- tion will be used. /etc/yum.conf /etc/yum/repos.d/ SEE ALSO
yum.conf (5) http://yum.baseurl.org/ AUTHORS
See the Authors file included with this program. BUGS
There are of course no bugs, but should you find any, you should first consult the FAQ section on http://yum.baseurl.org/wiki/Faq and if unsuccessful in finding a resolution contact the mailing list: yum-devel@lists.baseurl.org. To file a bug use http://bugzilla.redhat.com for Fedora/RHEL/Centos related bugs and http://yum.baseurl.org/report for all other bugs. 27 April 2007 reposync(1)
All times are GMT -4. The time now is 12:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy