ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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...
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.