The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cut awk dummy question :) sopel39 UNIX for Dummies Questions & Answers 14 11-14-2007 10:14 AM
using grep for a dummy mkosucu UNIX for Dummies Questions & Answers 3 10-28-2007 12:56 AM
Curious Dummy highway39 UNIX for Dummies Questions & Answers 1 08-31-2006 04:22 PM
Dummy Needs Help amygdala UNIX for Dummies Questions & Answers 4 08-31-2001 08:14 PM
Real Dummy here!! Keith UNIX for Dummies Questions & Answers 2 02-06-2001 10:18 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-09-2006
Registered User
 

Join Date: Feb 2006
Posts: 66
Dummy need help :(

This drive me nut, any can show me how to do it ??


str1='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Modify 10002 20002 30003 40004'

and str2='Case Modify 10001'

if str1 ~ str2
then str1='Report Create 3417176211|Case Modify 10002 20002 30003 40004'


Thanks,
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-09-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Code:
#!/bin/ksh

str1='Case Modify 10001 20002 30003 40004|Report Create 3417176211|Case Modify 1 0002 20002 30003 40004'

str2='Case Modify 10001'

echo "str1 BEFORE->[${str1}]"
str1=$(echo "${str1}" | nawk -F'|' -v str2="${str2}" '$0 ~ str2 { print $2,$3}')
echo "str1 AFTER->[${str1}]"
next time..... if you could show what you've tried you might get a more willing to help audience.
Reply With Quote
  #3 (permalink)  
Old 03-10-2006
Registered User
 

Join Date: Feb 2006
Posts: 66
The problem I got is if str1 keep larger , if str1 !~ str2 then str2 will be add to str1
str1 = str2 + str1
and keep go on
and we really dont know what field str2 is matching in str1 , we only know we should remove the extra part if they matched.

Sorry for my English
Reply With Quote
  #4 (permalink)  
Old 03-10-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Quote:
Originally Posted by sabercats
The problem I got is if str1 keep larger , if str1 !~ str2 then str2 will be add to str1
str1 = str2 + str1
and keep go on
and we really dont know what field str2 is matching in str1 , we only know we should remove the extra part if they matched.

Sorry for my English
sorry, cannot parse the above....
have you tried the suggested solution? And if so, what was the result of that?
Reply With Quote
  #5 (permalink)  
Old 03-10-2006
Registered User
 

Join Date: Feb 2006
Posts: 66
you mean this ?
Quote:
echo "str1 BEFORE->[${str1}]"
str1=$(echo "${str1}" | nawk -F'|' -v str2="${str2}" '$0 ~ str2 { print $2,$3}')
echo "str1 AFTER->[${str1}]"
I think if we know the position where it match, then we can follow your code. But we dont know . I am thinging to use subtr then we never have subtract
If str1 = 'A|B|C|D|E..'
and str2 is A or B or D or E ...
then str1 will remove A or B or C or D or E
then str1 = str1 "|" str2 again
Reply With Quote
  #6 (permalink)  
Old 03-10-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Quote:
Originally Posted by sabercats
you mean this ?


I think if we know the position where it match, then we can follow your code. But we dont know . I am thinging to use subtr then we never have subtract
If str1 = 'A|B|C|D|E..'
and str2 is A or B or D or E ...
then str1 will remove A or B or C or D or E
then str1 = str1 "|" str2 again
sorry I don't understand what you're trying to say/do......
Again have you tried the posted code?

Can you show an example where the output is not what you desire AND provide a sample of desired results.
Reply With Quote
  #7 (permalink)  
Old 03-10-2006
Registered User
 

Join Date: Feb 2006
Posts: 66
Here is my code and I solved the problem with CDxAcct but can not figure out how to remove the duplicate "Case Modify ID" or remove "Case Access ID"

Remove duplicate ???
Cheers,
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0