Printf example with %q

[root@test1 scripts]# printf "%q %q\n" "Alpha System corp" "MG Road, Bangalore" >company.txt
[root@test1 scripts]# read company location < company.txt
[root@test1 scripts]# printf company
company[root@test1 scripts]# printf $company
Alpha[root@test1 scripts]# printf %q $company
AlphaSystemcorp[root@test1 scripts]# printf %q "$company"
Alpha\ System\ corp[root@test1 scripts]# printf %q\n "$company"
Alpha\ System\ corpn[root@test1 scripts]# printf "%q\n" "$company"
Alpha\ System\ corp

[root@test1 scripts]# cat company.txt
Alpha\ System\ corp MG\ Road\,\ Bangalore --> "\" is because of %q if u gave %s it will read only first coming space.

[root@test1 scripts]# printf "%q\n" "$location"
MG\ Road\,\ Bangalore
[root@test1 scripts]# printf "%s\n" "$location"
MG Road, Bangalore
[root@test1 scripts]# printf "%s\n" "$company"
Alpha System corp

Comments

Popular posts from this blog

How to delete SEA in VIOS

Webmin configuration for LDAP

Sample questions and answers for AWS Associate Solutions Architect Certification ---> AWS exam dumps