New line in while loopHow to name a file in the deepest level of a directory treeBash while loop read from...
Transiting through Switzerland by coach with lots of cash
Is negative resistance possible?
Why didn't Snape ask Dumbledore why he let "Moody" search his office?
"Es gefällt ihm." How to identify similar exceptions?
Is there a penalty for switching targets?
Is having your hand in your pocket during a presentation bad?
Applying UK Visit Visa Application from AU
What is the origin of the minced oath “Jiminy”?
Spectrometer vs Spectrometry vs Spectroscopy
Is there a difference between historical fiction and creative non-fiction?
This fell out of my toilet when I unscrewed the supply line. What is it?
Would Great Old Ones care about the Blood War?
The work of mathematicians outside their professional environment
What's the difference between motherboard and chassis?
Can something have more sugar per 100g than the percentage of sugar that's in it?
What benefits are there to blocking most search engines?
Can I voluntarily exit from the US after a 20 year overstay, or could I be detained at the airport?
Can't change the screenshot directory because "com.apple.screencapture: command not found"
How can three vectors be orthogonal to each other?
A goat is tied to the corner of a shed
Spiral Stumper Series: Instructionless Puzzle
Why is the time of useful consciousness only seconds at high altitudes, when I can hold my breath much longer at ground level?
Why is there "Il" in "Il mio tesoro intanto"?
In what sense is SL(2,q) "very far from abelian"?
New line in while loop
How to name a file in the deepest level of a directory treeBash while loop read from colon-delimited list of paths using IFSHow to prevent script from deleting itselfnull string as command in while loop: empty/null-commandShell scripting help text file into arrayConcatenating a list of files using For loopListing number of files in each folder where folder name matches a patternThe $@ variable is not working in a for loop, trying to iterate through a users listHow can I grep each file in a directory for a keyword and output the keyword and the filename it was found in?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}
I have this code to generate a list of fake names and addresses but it keeps outputting them all on one line. How do I output each name and corresponding address on its own line?
#!/bin/bash
count=0
while [ $count -lt 10 ]
do
name=$(faker name)
address=$(faker address)
echo $name, $address >> name-address.txt
count=$((count+1))
done
bash newlines
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment
|
I have this code to generate a list of fake names and addresses but it keeps outputting them all on one line. How do I output each name and corresponding address on its own line?
#!/bin/bash
count=0
while [ $count -lt 10 ]
do
name=$(faker name)
address=$(faker address)
echo $name, $address >> name-address.txt
count=$((count+1))
done
bash newlines
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
This works fine for me. (I don't have faker)
– Stephen Rauch
Apr 10 '17 at 0:42
As written, the name and address will be outputted with a comma in-between them, on one line. The next name and address will be on the next line. If this is not true for you, then make sure you have Unix line-endings in you script.
– Kusalananda♦
Apr 10 '17 at 7:35
Is it all on one line if you docat name-address.txt
? Or only when you copy it to Windows and use Notepad?
– Barmar
Apr 10 '17 at 19:17
add a comment
|
I have this code to generate a list of fake names and addresses but it keeps outputting them all on one line. How do I output each name and corresponding address on its own line?
#!/bin/bash
count=0
while [ $count -lt 10 ]
do
name=$(faker name)
address=$(faker address)
echo $name, $address >> name-address.txt
count=$((count+1))
done
bash newlines
I have this code to generate a list of fake names and addresses but it keeps outputting them all on one line. How do I output each name and corresponding address on its own line?
#!/bin/bash
count=0
while [ $count -lt 10 ]
do
name=$(faker name)
address=$(faker address)
echo $name, $address >> name-address.txt
count=$((count+1))
done
bash newlines
bash newlines
edited Apr 10 '17 at 1:43
Jeff Schaller♦
50.2k11 gold badges74 silver badges167 bronze badges
50.2k11 gold badges74 silver badges167 bronze badges
asked Apr 10 '17 at 0:32
Thesystem32Thesystem32
11 bronze badge
11 bronze badge
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
This works fine for me. (I don't have faker)
– Stephen Rauch
Apr 10 '17 at 0:42
As written, the name and address will be outputted with a comma in-between them, on one line. The next name and address will be on the next line. If this is not true for you, then make sure you have Unix line-endings in you script.
– Kusalananda♦
Apr 10 '17 at 7:35
Is it all on one line if you docat name-address.txt
? Or only when you copy it to Windows and use Notepad?
– Barmar
Apr 10 '17 at 19:17
add a comment
|
This works fine for me. (I don't have faker)
– Stephen Rauch
Apr 10 '17 at 0:42
As written, the name and address will be outputted with a comma in-between them, on one line. The next name and address will be on the next line. If this is not true for you, then make sure you have Unix line-endings in you script.
– Kusalananda♦
Apr 10 '17 at 7:35
Is it all on one line if you docat name-address.txt
? Or only when you copy it to Windows and use Notepad?
– Barmar
Apr 10 '17 at 19:17
This works fine for me. (I don't have faker)
– Stephen Rauch
Apr 10 '17 at 0:42
This works fine for me. (I don't have faker)
– Stephen Rauch
Apr 10 '17 at 0:42
As written, the name and address will be outputted with a comma in-between them, on one line. The next name and address will be on the next line. If this is not true for you, then make sure you have Unix line-endings in you script.
– Kusalananda♦
Apr 10 '17 at 7:35
As written, the name and address will be outputted with a comma in-between them, on one line. The next name and address will be on the next line. If this is not true for you, then make sure you have Unix line-endings in you script.
– Kusalananda♦
Apr 10 '17 at 7:35
Is it all on one line if you do
cat name-address.txt
? Or only when you copy it to Windows and use Notepad?– Barmar
Apr 10 '17 at 19:17
Is it all on one line if you do
cat name-address.txt
? Or only when you copy it to Windows and use Notepad?– Barmar
Apr 10 '17 at 19:17
add a comment
|
1 Answer
1
active
oldest
votes
For one, this is not a for
loop that you are using, rather a while
loop.
And you should get in the habit of quoting your variables:
echo $name, $address
==> echo "$name, $address"
to avoid mishaps and keep the results predictable.
Use printf
utility in place of echo
:
printf '%s, %sn' "$name" "$address" >> name_address.txt
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
Yes, probably the line feed char. Try thisecho -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
add a comment
|
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f358011%2fnew-line-in-while-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
For one, this is not a for
loop that you are using, rather a while
loop.
And you should get in the habit of quoting your variables:
echo $name, $address
==> echo "$name, $address"
to avoid mishaps and keep the results predictable.
Use printf
utility in place of echo
:
printf '%s, %sn' "$name" "$address" >> name_address.txt
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
Yes, probably the line feed char. Try thisecho -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
add a comment
|
For one, this is not a for
loop that you are using, rather a while
loop.
And you should get in the habit of quoting your variables:
echo $name, $address
==> echo "$name, $address"
to avoid mishaps and keep the results predictable.
Use printf
utility in place of echo
:
printf '%s, %sn' "$name" "$address" >> name_address.txt
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
Yes, probably the line feed char. Try thisecho -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
add a comment
|
For one, this is not a for
loop that you are using, rather a while
loop.
And you should get in the habit of quoting your variables:
echo $name, $address
==> echo "$name, $address"
to avoid mishaps and keep the results predictable.
Use printf
utility in place of echo
:
printf '%s, %sn' "$name" "$address" >> name_address.txt
For one, this is not a for
loop that you are using, rather a while
loop.
And you should get in the habit of quoting your variables:
echo $name, $address
==> echo "$name, $address"
to avoid mishaps and keep the results predictable.
Use printf
utility in place of echo
:
printf '%s, %sn' "$name" "$address" >> name_address.txt
answered Apr 10 '17 at 0:44
user218374
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
Yes, probably the line feed char. Try thisecho -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
add a comment
|
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
Yes, probably the line feed char. Try thisecho -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
This still doesn't work, could it be my notepad formatting?
– Thesystem32
Apr 10 '17 at 1:00
Yes, probably the line feed char. Try this
echo -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
Yes, probably the line feed char. Try this
echo -e "$name, $addressrn" >> name-address.txt
– GMaster
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
yes. then run a unix2dos on the name_address,txt before opening it in Notepad.
– user218374
Apr 10 '17 at 1:15
add a comment
|
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f358011%2fnew-line-in-while-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This works fine for me. (I don't have faker)
– Stephen Rauch
Apr 10 '17 at 0:42
As written, the name and address will be outputted with a comma in-between them, on one line. The next name and address will be on the next line. If this is not true for you, then make sure you have Unix line-endings in you script.
– Kusalananda♦
Apr 10 '17 at 7:35
Is it all on one line if you do
cat name-address.txt
? Or only when you copy it to Windows and use Notepad?– Barmar
Apr 10 '17 at 19:17