Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

cat as a script (See related posts)

# cf. http://www.linuxjournal.com/article/7385 (comments)

function shcat() {
   if [[ $# -eq 0 ]]; then
      while read -r -d $'\n'; do printf "%s\n" "${REPLY}"; done
   else
      for F in "$@"; do
         while read -r -d $'\n'; do printf "%s\n" "${REPLY}"; done < "$F"
      done
   fi
   return 0
}


echo hello world | shcat
shcat file.txt | nl

You need to create an account or log in to post comments to this site.