Sponsored Content
Top Forums Shell Programming and Scripting Perl - use search keywords from array and search a file and print 3rd field when matched Post 302743673 by chidori on Thursday 13th of December 2012 06:00:33 AM
Old 12-13-2012
@ Guru , i am using perl default variable $_ . Hence i have not used a separate variable in foreach loop.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl regular expressions and field search

Hello guys/gals, i am sorry as this is probably very simply but i am slowly learning perl and need to convert some old korn shell scripts. I need to be able to search a file line by line but only match a string at particular location on that line, for example character 20-30. So my file... (4 Replies)
Discussion started by: dynamox
4 Replies

2. Shell Programming and Scripting

search of string from an array in Perl

Hi All I want to search a string from an array in Perl. If a match occurs, assign that string to a variable else assign 'No match'. I tried writing the script as follows but it's in vain. Please help me.. #!/usr/bin/perl use strict; my $NER; my @text=("ORG","PER"); ... (4 Replies)
Discussion started by: my_Perl
4 Replies

3. Shell Programming and Scripting

Search a file with keywords

Hi All I have a file of format asdf asf first sec endi asdk rt 123 ferf dfg ijglkp (7 Replies)
Discussion started by: mailabdulbari
7 Replies

4. Shell Programming and Scripting

Perl - search and replace a particular field

Hi, I have a file having around 30 records. Each record has 5 fields delimited by PIPE. Few records in the file having Junk characters in the field2 and field4. I found the junk charcter and I tested it and replace the junk with space with the command below perl -i -p -e "s/\x00/ /g"... (1 Reply)
Discussion started by: ramkrix
1 Replies

5. Shell Programming and Scripting

how to search array and print index in ksh

Hi, I am using KSH shell to do some programming. I want to search array and print index value of the array. Example.. nodeval4workflow="DESCRIPTION ="" ISENABLED ="YES" ISVALID ="YES" NAME="TESTVALIDATION" set -A strwfVar $nodeval4workflow strwfVar=DESCRIPTION=""... (1 Reply)
Discussion started by: tmalik79
1 Replies

6. Shell Programming and Scripting

Better and efficient way to reverse search a file for first matched line number.

How to reverse search for a matched string in a file. Get line# of the first matched line. I am getting '2' into 'lineNum' variable. But it feels like I am using too many commands. Is there a better more efficiant way to do this on Unix? abc.log aaaaaaaaaaaaa bbbbbbbbbbbbb... (11 Replies)
Discussion started by: kchinnam
11 Replies

7. UNIX and Linux Applications

Perl Script to read an excel file into an array and search in the UNIX directories

Hi, I want the Perl script with versions 5.8.2 and 5.8.5 starting with #!/usr/bin/perl The Perl program should read the excel file or text file line by line and taking into an array and search in the UNIX directories for reference file of .jsp or .js or .xsl with path .The Object names... (2 Replies)
Discussion started by: pasam
2 Replies

8. UNIX for Advanced & Expert Users

Search and replace a array values in perl

Hi, i want to search and replace array values by using perl perl -pi -e "s/${d$i]}/${b$j]}" *.xml i am using while loop for the same. if i excute this,it shows "Substitution replacement not terminated at -e line 1.". please tell me what's wrong this line (1 Reply)
Discussion started by: arindam guha
1 Replies

9. UNIX for Dummies Questions & Answers

Search file and print everything except multiple search terms

I'm trying to find a way to search a range of similar words in a file. I tried using sed but can't get it right:sed 's/\(ca01\)*//'It only removes "ca01" but leaves the rest of the word. I still want the rest of the information on the lines just not these specific words listed below. Any... (3 Replies)
Discussion started by: seekryts15
3 Replies

10. UNIX for Beginners Questions & Answers

Search a string inside a pattern matched block of a file

How to grep for searching a string within a begin and end pattern of a file. Sent from my Redmi 3S using Tapatalk (8 Replies)
Discussion started by: Baishali
8 Replies
ODFFILESEARCH(1p)					User Contributed Perl Documentation					 ODFFILESEARCH(1p)

NAME
odffilesearch - File selection by keywords SYNOPSIS
odffilesearch -R "D:Documents*.odt" openoffice desktop XML produces the list of the ODF Text documents present in the given directory and its subdirectories, and containing the words "openoffice", "desktop" AND "XML" odffilesearch -command "rm -f %f" "*.ods *.odt" lost dismiss cancel executes the "rm -f filename" (i.e. deletes the file in a Unix system) for each ODT or ODS file present in the current directory and containing the words "lost", "dismiss" AND "cancel" USAGE
odffilesearch [-options] <file filter> <keyword list> DESCRIPTION
This utility allows the user to retrieve a list of files matching a given set of keywords or regular expressions. A file is selected when it contains, in its text and/or in its metadata (title, subject, keywords or description), all the given search strings. The selected files are echoed to the standard output (one file per line), so this utility can be used as a filter piping its results to another program. Alternatively, a given shell command can be launched by the script each time a file matches, allowing on-the-fly processing of the selected documents. The files filter may content one or more space-separated paths. Each path may content jokers. So it's possible to explore several directories and/or several filename patterns. All the arguments after the file filter are processed as search criteria. OPTIONS
-R -recursive include the subdirectories of each given search directory -verbose -trace -debug echo some processing comments -warnings activate the warning messages of the OpenOffice::OODoc API -log <file> like -verbose, but then messages are sent to the given file and don't pollute the standard output -result <file> -output <file> send the list of matching files to the given file and not to the standard output -criteria <file> get search criteria from a file (one per line); the loaded search keywords may be combined with additional criteria passed with the command line, if any. -command <command> -exec <command> execute a shell command for each matching file ; if the command string contains "%f", this substring is replaced with the name of the selected file ; if this option is provided, the selection list is not echoed to the standard output ; if -verbose is on, the value returned by the command is echoed -encoding <encoding> selects the user's character set ; this option is mandatory if one or more search criteria contain characters not belonging to the default character set perl v5.14.2 2008-05-04 ODFFILESEARCH(1p)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy