leo's profileIamLeoPhotosBlogLists Tools Help
    5/25/2008

    一段代码,实现从一个字符串集中删除一个包含某个词的子字符串

    rpms="abcdef/1234/aef 1234/56a/del i/love/you /pced/glibc-common-1.2 /home/e/f.d"
    rpms_new=`echo $rpms | awk '{split($0,rpms_tmp," ");for(i in rpms_tmp) if(!($i~/glibc-common/))printf("%s ",$i);printf("\n");}'`
    echo $rpms
    echo $rpms_new



    显示结果为
    abcdef/1234/aef 1234/56a/del i/love/you /pced/glibc-common-1.2 /home/e/f.d
    /home/e/f.d abcdef/1234/aef 1234/56a/del i/love/you

    但不知道为什么顺序会变

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://lichl.spaces.live.com/blog/cns!5CE9FA4ACA698F15!2152.trak
    Weblogs that reference this entry
    • None