perl -p -i -e 'BEGIN { print "{" } END { print "}" }' filename.txt #### echo "{" >tmp cat filename.txt >>tmp echo "}" >>tmp mv tmp filename.txt