DEV Community

Discussion on: Stupid Short: Bash's |, >, >>, <, 2>>, 2> Operators

Collapse
 
ferricoxide profile image
Thomas H Jones II

Another really useful redirection-related BASHism: <( ):

Useful if, say, you want to check to see if a local file and an S3-hosted file are the same:

$ sha256sum <( aws s3 cp s3://BUKKIT1/file - ) ./file
d20c7a50c3ac734230b08dbe2cb9122634c2dd040eee56ebd8101bef455dbb88 */dev/fd/63
c204dbfa154fc4801bdaac298584815bbd1b4a968a2349dd17f1e7c459904d41 *file
Enter fullscreen mode Exit fullscreen mode

Similarly, can be used for things like diffing two streams:

diff <( aws s3 cp s3://BUKKIT1/file - ) <( aws s3 cp s3://BUKKIT2/file - )
Enter fullscreen mode Exit fullscreen mode