simple scripting question
is there anyway to assign a carriage return to a variable? just i regular bash scripting.
space="\n" just ends up printing \n in the middle of the text instead of seperating it with a carriage return. any help? |
Code:
#!/bin/sh Code:
# . test.sh |
i think i tried that. or atleast something like that. anyway, i tried it like you did just to see. it works for the print out like that put when i use it in my array....which is what i've been testing most of this on before i turned here.... it didn't work. you can see the exact same variable is used for your test and mine. it works on yours but not mine. it just enters a space. not a return. why?
//***************************************\ #!/bin/bash hi="hi" space=" " #space2="******" space2=' ' goodbye="goodbye" i=0 HELLO=' ' #Spare out entries into array #priming read array3[0]=${hi}$HELLO${goodbye} echo ${array3[i]} #echo $i echo "hello $HELLO there dude" //***************************************\ # ./carriage_return.sh hi goodbye hello there dude |
The echo command in bash will allow you to enter a newline or carriage return by using \n and \r respectively. You may have to use "echo -e \n" or "echo -e \r" (without the quotes). The -e is supposed to allow echo to use these 'special characters'. Try it both ways to learn...:cool:
|
maillion...i understand that. the problem is assigning that value into the middle of an array of characters. that's the problem. see the code above for what i'm trying to do. i want to be able to assign a carriage return between "hi" and "goodbye" in the array3[0] array.....sorry if i'm missunderstanding. i just wanted you to know what i was trying to do.
|
Using the -e with echo works.
Code:
#!/bin/bash |
sweet. now i under stand. thnx
|
All times are GMT -5. The time now is 03:50 PM. |