DESTINATION="${SOURCE}" strcat(destination, source) <--> DESTINATION="${DESTINATION}${SOURCE}" -- Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html Dept. of Physics, Univ. of Padova, Italy ROT13: vasa.vg [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Maurizio [ip] => mlo@foobar.it [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> anything similar to C string manipulation functions in shell scripting language - UNIX Programming

anything similar to C string manipulation functions in shell scripting language - UNIX Programming

anything similar to C string manipulation functions in shell scripting language...

  1. #1

    Default anything similar to C string manipulation functions in shell scripting language

    anything similar to C string manipulation functions in shell
    scripting language
    George Guest

  2. #2

    Default Re: anything similar to C string manipulation functions in shell scripting language

    George Kooper <com > writes:
     

    strcpy(destination, source) <--> DESTINATION="${SOURCE}"
    strcat(destination, source) <--> DESTINATION="${DESTINATION}${SOURCE}"

    --
    Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html
    Dept. of Physics, Univ. of Padova, Italy ROT13: vasa.vg
    Maurizio Guest

  3. #3

    Default Re: anything similar to C string manipulation functions in shellscripting language

    George Kooper <com > wrote: 

    Read the shell man page section on parameter expansion.
    The capabilities are fairly extensive.

    --
    Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
    Ukpeagvik (Barrow, Alaska) com
    Floyd Guest

  4. #4

    Default Re: anything similar to C string manipulation functions in shell scripting language

    On Tue, 17 Feb 2004 at 12:13 GMT, George Kooper wrote: 

    I just whipped these up in answer to this question. Most are so
    trivial that I woudn't use them. In some, the function is more
    complex than a simple in-line statement.

    They more or less conform to the equivalent C functions. There's
    no error checking, and they are not thoroughly tested:

    strlen() { ## strlen STRING
    echo ${#1}
    }

    strcpy() { ## strcpy VAR STRING
    eval "$1=\"$2\""
    }

    strncpy() { ## strcpy VAR STRING N
    eval "$1=\"`printf "%0.${3}s\" \"$2\"`\""
    }

    strcat() { ## strcat VAR STRING
    eval "$1=\"\${$1}$2\""
    }

    strncat() { ## strncat VAR STRING N
    eval "$1=\"\${$1}`printf "%${3}.${3}s" $2`\""
    }

    strchr() { ## STRING CHAR
    echo ${1#${1%$2*}}
    }

    strrchr() { ## STRING CHAR
    echo ${1#${1%%$2*}}
    }

    strcmp() { ## strcmp STRING1 STRING2
    [ "$1" = "$2" ] && return
    [ "$1" \< "$2" ] && return 1
    return 2
    }

    strncmp() { ## strcmp STRING1 STRING2 N
    eval strcmp `printf "\"%0.$3s\" \"%0.$3s\"" "$1" "$2"`
    }

    strdup() { ## strdup STRING
    printf "%s\n" "$1"
    }

    strndup() { ## strdup STRING N
    printf "%0.${2}s\n" "$1"
    }

    strtok() { ## strtok STRING DELIM
    [ -n "$1" ] && _STRTOK=$1
    _STRTOK=${_STRTOK%[$2]*}
    printf "%s\n" "$_STRTOK"
    }


    --
    Chris F.A. Johnson http://cfaj.freeshell.org
    ================================================== =================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
    Chris Guest

  5. #5

    Default Re: anything similar to C string manipulation functions in shellscripting language



    George Kooper wrote:
     

    Not in sh. perl has such, and there are many progs you can call
    with any shell that will manipulate strings. (eg sed, awk, ...)

    try
    man <whatever_shell_you_use>

    to see what it has.

    Speaking only for myself,

    Joe Durusau

    joe Guest

  6. #6

    Default Re: anything similar to C string manipulation functions in shell scripting language

    George Kooper <com > wrote: 

    Please provide more detail about what you're trying to do. Include such
    arcane information as which shell (aka "shell scripting language") you're
    using, what external programs you have available, and what you've tried so far
    to solve what problems.

    The 'expr' command is available on almost all unices, and covers at least the
    basic needs.
    --
    Mark Rafn net <http://www.dagon.net/>

    Mark Guest

Similar Threads

  1. inventing a scripting language?
    By Nicknamenick in forum Macromedia Dynamic HTML
    Replies: 3
    Last Post: April 4th, 12:25 PM
  2. Required Perl Developer w/ UNIX. SQL and Shell Scripting.
    By iLogicnet Solutions Team in forum PERL Modules
    Replies: 0
    Last Post: March 24th, 11:41 PM
  3. what is similar to shell `du' in perl
    By Harry in forum PERL Beginners
    Replies: 5
    Last Post: March 4th, 06:57 PM
  4. Perl as embedded scripting language
    By Paul Vernaza in forum PERL Miscellaneous
    Replies: 1
    Last Post: August 4th, 02:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •