News for hackers. Stuff that matters.
Re:What programming languages are used most on weekends? by freehunter on Tuesday February 07, 2017 @09:02PM (#13595038)
Then again, sed works differently on different platforms, and awk is not the same as gawk or nawk, both of which have many more features than standard awk. If you're used to the GNU implementation, you might be surprised to find your script doesn't work on a system without the gawk implementation.

On Linux, I can use this sed command: sed -i ‘s/^”//’ example.txt

That deletes any quotation marks that are at the beginning of a line. It does it in-place, and while you have the option to rename the old file and replace it with a new file with the original name (using "sed -i.bak ‘s/^”//’ example.txt" would move the existing example.txt file to example.txt.bak and write a new one in-place), if you leave out the .bak, it just writes it in-place with no backup file.

On OS X, though, that command won't work. You have to specify a backup file, even if it's blank. "sed -i “” ‘s/^”//’ example.txt" would replace the text in-place without a backup. sed -i “.bak” ‘s/^”//’ example.txt would replace the file and move the original to "example.txt.bak".

Even with sed and awk, you still have to stop and wonder if it will work cross-platform.

Re:What programming languages are used most on weekends? by wcarron on Tuesday February 07, 2017 @10:21PM (#13595411)
This is why I have gripes about the OS X command line. I can't confidently use the scripts I do on Ubuntu/Mint/Debian. Like, get with the program, Apple. It infuriates me and I'm moving entirely off their platform as soon as my Mac kicks the bucket.
Re:What programming languages are used most on weekends? by johnmaguire2013 on Tuesday February 07, 2017 @11:45PM (#13595825)
OS X is not Linux. It's a BSD-derivative, and doesn't use the GNU toolchain. It isn't that it's "not with the program." It's that it's not the operating system, or toolchain, you're familiar with. Install homebrew and GNU tools[1] if you want them.

If you used an operating system that shipped with BusyBox, you'd be similarly frustrated. But operating systems are tradeoffs with pros/cons. Using a different set of tools makes it distinct, not "out of date".

1. https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-c...

Re:What programming languages are used most on weekends? by wcarron on Wednesday February 08, 2017 @11:44AM (#13599666)
Oh, my mistake. I was under the impression that sed/awk/grep/ack/etc etc were part of the POSIX standard toolchain, rather than the GNU toolchain.
Re:What programming languages are used most on weekends? by bootload on Wednesday February 08, 2017 @04:30AM (#13596996)
"OS X is not Linux. It's a BSD-derivative, and doesn't use the GNU toolchain."

True, but I was thinking awk/sed was a good multi OS tool with minimal code effect.

Re:What programming languages are used most on weekends? by base698 on Wednesday February 08, 2017 @08:58AM (#13598172)
I have a script which installs and aliases all the equivalent GNU commands on OSX. You can fix a lot of the annoyances.
Re:What programming languages are used most on weekends? by bootload on Wednesday February 08, 2017 @04:27AM (#13596982)
"Then again, sed works differently on different platforms"

Well that kills my idea why to use awk/sed. What would you use @freehunter?

Re:What programming languages are used most on weekends? by pjmlp on Wednesday February 08, 2017 @08:34AM (#13598032)
Perl, Python, Ruby
Re:What programming languages are used most on weekends? by bootload on Wednesday February 08, 2017 @08:02PM (#13603720)
True, defeats the idea of a one liner in bash/awk/sed.
Re:What programming languages are used most on weekends? by freehunter on Wednesday February 08, 2017 @08:08PM (#13603751)
Well the beauty of one-liners is that they're quick and dirty. They don't need to be portable, you don't usually maintain a one-liner for years. If you need something portable, you should use a real cross-platform language like Perl, Python, etc. Something that's independent of the OS you're running.
Re:What programming languages are used most on weekends? by bootload on Thursday February 09, 2017 @07:25PM (#13612305)
"Well the beauty of one-liners is that they're quick and dirty. They don't need to be portable, you don't usually maintain a one-liner for years."

Given that description, I'd agree. Now I understand the crux of the problem, problem solved using disposable code in terse language or script.