- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Find the String-need help in Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 02:39 PM
тАО09-01-2005 02:39 PM
Find the String-need help in Script
I have a file abc.txt,i want to search a word like abc in 5the column and 8th row,once i find that word,i should compare that string(find the string) to another file xyz.txt,once it match the abc.txt wil move to some other folder like /tmp --need script for help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 04:07 PM
тАО09-01-2005 04:07 PM
Re: Find the String-need help in Script
Here is how to get a list of files that contain a string found in an other file on a viven line, in a given column:
grep -l `awk '(NR==8){print substr($0,5,3)}' abc.txt` *.txt
I'm sure you can take it form there...
(Oh... and it will find abc.txt :-)
Hein.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 04:11 PM
тАО09-01-2005 04:11 PM
Re: Find the String-need help in Script
But I Once i find that abc word from abc.txt then i will find that word in xyz.txt to get the variable
for eg:
In xyz.txt
xyz=abc
i want to output abc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 04:37 PM
тАО09-01-2005 04:37 PM
Re: Find the String-need help in Script
Well , it is not enitrely clear to me what syntax/filenames you can rely on>
An answer to your last question might be:
grep `awk '(NR==8){print substr($0,5,3)}' abc.txt` xyz.txt | cut -f 2 -d=
Here is what that does for me:
> cat x
wergewrgwehrweh
rthwrthrwthrwth
etrrgertgwetrgw
122345XXX124253
fw34t23t2yt5425y
> cat y
erfer=1244
XXX=test
agrwe
> grep `awk '(NR==8){print substr($0,7,3)}' x` y | cut -f 2 -d=
test
If this does not get you going, then you may want to re-reply with (a text attachment with) a sample input file set and sample output action.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 05:45 PM
тАО09-01-2005 05:45 PM
Re: Find the String-need help in Script
eg:
abc.txt
THe
Luck to the word
jl abc llk
xyz.txt
Land ...
abc = test
i want to take a string abc from abc.txt then if that string(abc) is present in xyz.txt then output of abc will diplay(Output:test) then the file abc.txt will move to /tmp folder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 05:51 PM
тАО09-01-2005 05:51 PM
Re: Find the String-need help in Script
if [[ $(awk '(NR==8) { print $5; }' abc.txt) = "abc" ]]
then
awk -F"=" '/abc/ { print $2 }' xyz.txt
mv abc.txt /tmp
fi
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 06:41 PM
тАО09-01-2005 06:41 PM
Re: Find the String-need help in Script
i want to take a string abc from abc.txt then if that string(abc) is present in xyz.txt then output of abc will diplay(Output:test) then the file abc.txt will move to /tmp folder
====
If you want to search abc anywhere in abc.txt and print Ouput: test then,
awk -F"=" '/abc/ { print "Ouput:"$2 }' xyz.txt
mv abc.txt /tmp
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-01-2005 09:05 PM
тАО09-01-2005 09:05 PM