I have a file fruits:
apple grapes banana orange By using
cat < fruits | tr "\n" "," It will give output as
apple,grapes,banana,orange, Here I want to print the file name also along with the output like
fruits|apple,grapes,banana,orange How can I do it?
If it is a variable like
$HEALTHYFRUITS
where we read all the fruits one by one and the file name is fruits
and
echo $HEALTHYFRUITS | tr "\n" ","
here I want to print
fruits|apple,grapes,banana,orange