1

How can I delete a newline character in bash script?

view story
linux-howto

http://stackoverflow.com – I have a little problem with a small script. The textfile has a lot of entries like: permission-project1-admin permission-project2-admin .... The script looks like this (indeed, it is an awful one but still helps me): #!/bin/bash for i in $(cat adminpermission.txt); do permission=$(echo $i | cut -f1) printf "dn:$permission,ou=groups,dc=domain,dc=com \n" printf "objectclass: groupOfUniqueNames \n" printf "objectclass: top \n" printf "description: \n" printf "cn:$permission \n\n" done The output looks fine, but because the textfile has a newline character at the end, the first line of (HowTos)