- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to match character
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
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
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
07-02-2012 11:21 AM
07-02-2012 11:21 AM
Re: script to match character
thx replies,
I am sorry that when I apply it to my real case , it still have problem , as in my real case , the master file has a bit difference Dennis Handly 's method is delimited by space only ( f1 f2 f3 is delimited by space ) , the real file is a bit complicate.
The below is the master file of the real case , in the string (eg. aaa bbb ccc ddd eee) , there are other space before this string .
#vi master.txt
"ffd" hg " gg"""""" aaa bbb ccc ddd eee " " "
"fd "jg "" """"" xxx yyy zzz mmm ooo " " "
"hdgd"jg"""fd""f"" ggg hhh iii jjj kkk " " "
I want to compare ( in my master file ) is
1) after 9 " , then
2) the 4th column of the string that delimited by space ,
can advise what can i do ?
thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2012 04:36 PM
07-02-2012 04:36 PM
Re: script to match character
I may be make it confued so I would like to clearly re-post my question .
I have a master file , the content is as below.
#vi master.txt
"d"""""""" aaa bbb ccc ddd eee " " "
"""y""d"""" xxx yyy zzz mmm ooo " " "
""f""""""" ggg hhh iii jjj kkk " " "
I also have some text files ,
eg.
#vi file1.txt
aaa
#vi file2.txt
bbb
#vi file3.txt
ccc
#vi file4.txt
ddd
I would like to check if the fourth column ( eg. ddd mmm jjj ) is exist in these text files , if not exist , then output this line , in this case , output the below ( as ddd exists in file4.txt )
"""y""d"""" xxx yyy zzz mmm ooo " " "
""f""""""" ggg hhh iii jjj kkk " " "
The requirement is check
1) after 9 " , and
2) the 4th column of the string that delimited by space .
can advise what can I do ? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2012 09:03 PM
07-02-2012 09:03 PM
Re: script to match character
>1) after 9 ", then
>2) the 4th column of the string that delimited by space
Ok, try this:
while read line; do
IFS_save=$IFS
IFS='"\n' # split on double quote
echo "$line" | read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11
IFS=$IFS_save
f10=${f10# *} # strip leading spaces
f10=${f10% *} # strip trailing spaces
echo "$f10" | read f1 f2 f3 f4 f5 # split on spaces
fgrep -q "$f4" file*.txt
if [ $? -ne 0 ]; then
echo "$line" # print original line if field not found
fi
done < master.txt
- « Previous
-
- 1
- 2
- Next »