Q:

Assigning a column with 100 char spaces while printing it in output text file using Shell Scripting

i just want to fetch lines from a csv file and print it line by line. the thing is the below code fetches the 4th column and prints it. What i want to do is, i just want to give 100 char spaces for that column printing. if that column has 10 chars i just wanna print that and rest 90 chars spaces should be empty in that line.
cat filename | awk -F"," '{print $4}'

A:

AWK has printf() function that support format. With format "%100s" and "%-100s" you can pad printed string with spaces from left or right:
 $ echo "a\nb\nc\nd" | awk '{ printf("|%10s|\n", $1);}'                                  
 |         a|
 |         b|
 |         c|
 |         d|
 $ echo "a\nb\nc\nd" | awk '{ printf("|%-10s|\n", $1);}'                                    
 |a         |
 |b         |
 |c         |
 |d         |
 $

