0

I am trying to create a file with a header as well as some extracts from the input files.. I am always getting space alignment issues through I am using fixed space..

Any advise pls.. Thanks, here is the sample code

# print header
printf '%-50s | %-30s | %-30s | %-30s | %-30s | %-30s %-5s \n' "FileName"  "Amount Rec" "Payments" "Total Adjustments"  "Adjustment Amount" "File Date" "|" >> $msgfile

for file in "$SEARCH_DIR"/*; do
  file=`basename "$file"`
  recamt=$(awk -F "*" '/BPR/{print $3}' $file)
  amount1=$(awk -F "*" '/TS3/{print $5}' $file)
  amount1=$(awk -F "*" '/PLB/{print $7}' $file)
  printf '%-50s | %-30s | %-30s | %-30s | %-30s | %-30s %-5s \n' "$file" "$recamt" "$amount1" "1" "$amount1" "$weekdate" "|" >> $msgfile

The output when I open it in notepad looks good, but when I send this as a email ( mailx), I see space issues the output.. Any thoughts ?

My output values as below..

xxxxxxx.xxxxx.xxxxxxxxx.txt | 906262.23 | 393 | 1 | 75297.4 | 06-Mar-2019 |

Anto
  • 3
  • 6
  • Attach it as a file or send it as html with a fixed width font or `pre` tag. For historical reasons, plain email is often not whitespace safe. – that other guy Mar 06 '19 at 20:39
  • Many years ago, I had the same issue when viewing mail in Outlook. The fix I stumbled on then was putting 2 spaces at the start of every line. What I do today is send it as an attachment. [This question](https://stackoverflow.com/q/17359/7552) has many good answers about how to do that. – glenn jackman Mar 06 '19 at 20:51

0 Answers0