Tab Indented Standard Input Redirect in Bash

I managed to forget how to redirect standard input (when you want to feed a bunch of lines to a program) in a bash script while still indenting and had to go digging around for it. So I figured I’d make a note here so I don’t forget again and for anyone else in the same boat. It’s just <<- instead of <<. For example if you want to keep indentation within a loop:

[bash] for i in 1 2 3 4;do catYou can use whatever you want to indicate the end of the input instead of EOF if it floats your boat (as long as you use the same thing both times) but unfortunately <<- doesn’t work with spaces for indentation (although I’m a tab man myself).

Bash/UNIX
Programmer

Comments (2)

Permalink

Reading Standard Input in a Bash Shell Script

I guess this is obvious to most people but it took me quite a while to dig it out on the internet. I wanted my bash script to be able to read from standard input like cat sourcefile.txt|bash myscript.bash. It turns out the standard input can be read from /dev/stdin. So if I wanted to sort the standard input, myscript.bash would look like: sort /dev/stdin

I think this is probably basic UNIX knowledge but I’m not a programmer.

Bash/UNIX
Programmer

Comments (6)

Permalink