In an Amazon s3 bucket we have Debian packages stored in different folders each folder contains different amount of files.
While calling Debian packages from the s3 bucket(AWS) the packages are separated with spaces. Now I need to convert those space-separated packages into a newline-separated list, i.e. one package file per line. The input line doesn't contain an equal amount of spaces.
Each directory contains a different number of Debian packages and at last after converting packages into line-by-line will store all packages(of the different folders) in one file.
input:
package1.deb package2.deb pacakge3.deb pacakge4.deb package5.deb
output:
package1.deb
package2.deb
package3.deb
pacakge4.deb
This is the current attempt for a function running in the background for different folders of s3 bucket
function convertSpaceToNewLine(){
for line in filename; do
cat $line| grep '.deb$'|tr [:space:] \\t | sed 's/\t\t*/\n/g' >> folder/newfile
done
}
I have tried many commands like truncate, awk, xargs -n 1, and sed. Thanks