0

I have a text file with 5 tab delineated columns, name, address etc I have a shell script menu in which one of the options is to view each row as tab delineated columns. I found a solution here

https://unix.stackexchange.com/questions/57222/how-can-i-use-column-to-delimit-on-tabs-and-not-spaces

This works perfectly when input into the command line as

vagrant@pc0:/vagrant$ cat AddressBook.txt | column -ts $'\t'

However when I put it into the shell script, it no longer delineates by tab, and instead by the letter t. Can anybody tell me why this is happening and/or suggest a possible remedy? Cheers!

Icarian
  • 117
  • 6
  • 1
    I'm guessing you are using `sh` instead of `bash` to run the script. – tripleee Oct 20 '18 at 12:33
  • 2
    Also tangentially that's a [useless use of `cat`](/questions/11710552/useless-use-of-cat) – tripleee Oct 20 '18 at 12:34
  • Yes I am, sorry, very new to shell scripting, running scripts as sh ./ is the only way that was presented in my lectures to date – Icarian Oct 20 '18 at 12:37
  • 1
    You can fix that either by switching to a literal tab in single quotes instead of the Bash-only "C-style" string `$'\t'`; or use `bash ./script-name` (or better yet put a valid shebang, `chmod +x ./scriptname`, and run it simply with `./scriptname`). More details in the duplicate. – tripleee Oct 20 '18 at 12:40
  • Very helpful, thank you! I'm not sure about columns default, I thought it was white space. I don't see anything on it at http://www.tutorialspoint.com/unix_commands/column.htm or using man column – Icarian Oct 20 '18 at 12:46
  • 1
    I already removed that comment; but as per the [man page](http://man7.org/linux/man-pages/man1/column.1.html), the default is to use any whitespace as delimiter. – tripleee Oct 20 '18 at 12:48

0 Answers0