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
----------


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
----------