hi to all must say that im new in linux and programing, under Bash im try to make a script using a video tutorial (Unix Shell Scripting Advanced) and the problem come when i try to print a list of users from data file (names.dat)
format:
name : Asurname : address : city
namee : Csurname1 : address1 : city1
nameee : Bsurname2 : address2 : city2
the exercies is to make print of the names.dat sorted by the 2nd column (surname) printing whitout the ":" in format like this :
name Asurname address city
nameee Bsurname2 address2 city2
namee Csurname1 address1 city1
in the tutorial he use this comand:
Code:
sort -t : +1 names.dat | awk -F : '{printf("%-14.14s%-16.16s%-20.20s%-15.15s%-6.6s%-5.5s\n", $1, $2, $3, $4, $5, $6)}' | more
i have try it whitout to see the answer to make it alone but was imposible to me to make each column to be line iget somting like this:
name Asurname address city
nameee Bsurname2 address2 city2
namee Csurname1 address1 city1
i have tryed to copy the code from the tutorial but dont work
this is my code :
Code:
awk -F : '{"print(%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s\n", $1, $2, $3, $4, $5, $6)}' names.dat | sort -k2 | more
maby the teacher in the tutorial use old version of the printf program whit my code i get somting like this :
Code:
%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s
%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s
%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s
%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s
%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s
%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s%-20.20s
MANY LINES OF THIS AND AFTER THE LIST OF NAMES
name Asurname address city
nameee Bsurname2 address2 city2
namee Csurname1 address1 city1
and whit the tutorial code i dont get nothing
need help and explication who work printf and the columns in line