Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Don't accidentally open huge text files from the Command Line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Don't accidentally open huge text files from the Command Line
Authored by: DaphneDiane on May 17, '11 08:17:03AM
From my experience bash actually has better argument handling then csh. Here's the same thing in bash. I called it edit so as to not overwrite the open command since that is also used to open other things besides text files.
edit() { for i in "$@"; do if [[ -e "$i" && ( $(stat -f%z "$i") -lt 200000000 ) ]]; then open -e "$i"; else echo "WARNING: $i is awfully big to open in a text editor" 1>&2; fi; done; }


[ Reply to This | # ]
Don't accidentally open huge text files from the Command Line
Authored by: robleach on Aug 21, '12 11:03:29AM

Note, the code only manipulates the command if -e is supplied, so you can open other file types without worry. Besides, you can escape the command using "\open ...". And as far as argument argument handling, I have not figured out a way in bash to refer to arguments to reproduce tcsh's ability using "!*" and "!!:3-5", etc.. It could just be that I'm not familiar enough with bash to know how to do it.



[ Reply to This | # ]