Find the answer to your Linux question:
Results 1 to 3 of 3
I have the following code (in KSH) Code: $sentence="abc,def,rtr" var1=`print $sentence | cut -f1 -d","` while [[ -n "${var1}" ]] #true if string length is not equal to zero do ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2005
    Posts
    2

    Escape Character needed for =


    I have the following code (in KSH)

    Code:
    $sentence="abc,def,rtr"
    var1=`print $sentence | cut -f1 -d","`
    while [[ -n "${var1}" ]] #true if string length is not equal to zero
    do
    	var1=`print $sentence | cut -f$j -d","`
    	newvar=$newvar" eg="$var1
    	let j=j+1
    done
    echo $newvar
    The problem with this is, when I echo $newvar, the concatenated string must hold something like eg=abc eg=def eg=rtr

    But it prints eg abc eg def eg rtr

    The '=' symbol is not printed

    I tried various escape methods like \ '' ``, nothing seems to work. I feel I am missing something here.

    Could someone point the mistake in the code?

    In the meantime, if I figure it out, I will post it.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,882
    Use the single-quote mark ' around such text, that should fix it (not the ` quote, but the ' quote).
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Oct 2005
    Posts
    2
    Thanks Roxoff for the reply,

    The problem was the I had a IFS="=" in the starting of the code to strip strings from a file.

    That had bothered this loop. (weird!, as I dont read anything)

    Thus I used a differnet IFS hust before that and ran it.

Posting Permissions

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