Reputation: 67
I have file:
cat abc.txt
Data is here
ASDF 1234
GHJKL 5678
!@#$% 0011
I am using command "(echo "Random data is:,"; cat abc.txt) | xargs > red1.csv"
I need to print in data in below format **
Random data is: Data is here
ASDF 1234
GHJKL 5678
!@#$% 0011
Upvotes: 0
Views: 474
Reputation: 18361
Used printf statement to play around with formatting and placement of strings. of course you need to modify it as per your requirement. you would have to play around value of variables v and j as per your requirement. Awk statement was used inside echo statement using command substitution.
echo "Random data is : $(awk -v f="%35s\n" -v j="%20s\n" 'NR>1{printf f,$0} NR==1 {printf j,$0}' abc.txt) "
Random data is : Data is here
ASDF 1234
GHJKL 5678
!@#$% 0011
Upvotes: 1