Skip to main content
added 52 characters in body
Source Link
Michael Mrozek
  • 95.8k
  • 40
  • 245
  • 236

If the last argument to a command is a filenametakes stdin input, you can move it toread the front by prefixing itinput from a file with <<filename. This can appear anywhere in the command, so these two lines are equivalent:

cat filename cat <filename <filename cat 

This is particularly useful for grep, as it placesallows you to place the expression at the end of the line, so you can quickly modify a grep command it by hitting Up, without needing to scroll left to get past the filename:

<filename grep 'expression' 

If the last argument to a command is a filename, you can move it to the front by prefixing it with <, so these two lines are equivalent:

cat filename <filename cat 

This is particularly useful for grep, as it places the expression at the end of the line, so you can quickly modify a grep command it by hitting Up, without needing to scroll left to get past the filename:

<filename grep 'expression' 

If a command takes stdin input, you can read the input from a file with <filename. This can appear anywhere in the command, so these lines are equivalent:

cat filename cat <filename <filename cat 

This is particularly useful for grep, as it allows you to place the expression at the end of the line, so you can quickly modify a grep command it by hitting Up, without needing to scroll left to get past the filename:

<filename grep 'expression' 
Post Made Community Wiki
Source Link
Michael Mrozek
  • 95.8k
  • 40
  • 245
  • 236

If the last argument to a command is a filename, you can move it to the front by prefixing it with <, so these two lines are equivalent:

cat filename <filename cat 

This is particularly useful for grep, as it places the expression at the end of the line, so you can quickly modify a grep command it by hitting Up, without needing to scroll left to get past the filename:

<filename grep 'expression'