Article 4RFDF Linux Script, Concatenation doing Odd Behavior

Linux Script, Concatenation doing Odd Behavior

by
Darrell22
from LinuxQuestions.org on (#4RFDF)
Dear Experts,

I'm using an old version of cygwin, and
trying to get a simple script to work.

Input:
text file of package names, packages_all.txt

Output:
supposed to be a list of commands
created by
concatenating strings together

But I keep getting weird results.

The first two strings concatenate and
echo to screen fine.

But when I try to add a third string,
it does not get appended to the end.
But to the front.

Please take a look at the examples.

Any ideas on how to get this simple task work?

Thanks a lot

-----------

Using cygwin

$ cat packages_all.txt
AUC
BH
DBI
DT
...
whisker
withr
xml2
xopen
xtable
yaml
zeallot

----------

while read LINE
do
prefix='install.packages( "'
echo $prefix$LINE
done < packages_all.txt

...
install.packages( "xopen
install.packages( "xtable
install.packages( "yaml
install.packages( "zeallot

- As expected

----------

while read LINE
do
prefix='install.packages( "'
suffix=')'
newline=$prefix$LINE
echo $newline
done < packages_all.txt

...
install.packages( "yaml
install.packages( "zeallot

- As expected
- $suffix unused

----------

while read LINE
do
prefix='install.packages( "'
suffix=')'
newline=$prefix$LINE$suffix
echo $newline
done < packages_all.txt

...
)nstall.packages( "xtable
)nstall.packages( "yaml
)nstall.packages( "zeallot

- $suffix gets appended to the front
overwriting the first character

----------

while read LINE
do
prefix='install.packages( "'
suffix=')'
newline=$prefix$LINE
echo $newline$suffix
done < packages_all.txt

...
)nstall.packages( "yaml
)nstall.packages( "zeallot

- $suffix gets appended to the front
overwriting the first character

----------latest?d=yIl2AUoC8zA latest?i=F1Eu0wrzN_s:N8L2OacGyuk:F7zBnMy latest?i=F1Eu0wrzN_s:N8L2OacGyuk:V_sGLiP latest?d=qj6IDK7rITs latest?i=F1Eu0wrzN_s:N8L2OacGyuk:gIN9vFwF1Eu0wrzN_s
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments