0

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 
3
  • 3
    Please reformat your question and make it more comprehensible Commented Aug 31, 2016 at 12:21
  • Can you check now if this works ? Commented Aug 31, 2016 at 13:08
  • Thanks alot it works exactly the same way it has to :) Commented Aug 31, 2016 at 13:10

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.