hi..i would ask about how to write over data to new file with BASH.
so..assume my data looks like this :
11
12
13
14
15
...and so on. It's always line by line. and that's for the first file.
i want to write over those numbers into second file but by using space. so my second file should be look like this :
11 12 13 14 15...and so on
i tried with :
echo $dataFromFirstFile > $2
which $2 is second argument for my second file.
but, i dont get what i want..
thanks before!
Solution given by bartus11 is best option to use here, but if you are interested to know how to achieve this using echo, use \c option which will suppress trailing newline:-
#!/bin/bash
while read line
do
echo -e "${line} \c" >> newfile
done < oldfile
echo -e "\n" >> newfile # put final newline