Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSH - How do I...

Status
Not open for further replies.
Oct 31, 2006
2
US
set names = (James Mary) <-- user inputs James and Mary

I need to output this to a file as The names are "James" "Mary" <-- in one line

This is what I have:
set namecount = $#names
echo The names are > file.txt
while (${namecount} != 0)
echo -n \"${names[$namecount]}\" >> file.txt
@ namecount = ($namecount -1)
end

The output is
The names are <-- line1
"James""Mary" <-- line2

I want them to be in the same line. How do I do that? Your help will be highly appreciated.
 
echo [!]-n[/!] The names are > file.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. It worked.
Now, how do I do

The names are "James""Mary" <-- line1
They are "James""Mary" <-- line2
 
Sorry, I don't csh scripting, but how about ...
Instead of processing ${names[$namecount]} and writing the data to a file, write the data to an 'ouput-string' in the loop in the form:
${outputstring} = "${outputstring}\"${names[$namecount]}\""

Then echo that to the file as many times on as many lines as you like.

I hope that helps.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top