Writing by shivdev on Tuesday, 26 of May , 2015 at 5:25 am
While using sed in-place edit through sed -i on MacOS X, you will run into the following error.
This will ERROR out
mac:tmp shivdev$ sed -i “s/Apr/May/g” x.log
sed: 1: “x.log”: extra characters at the end of x command
Using an empty extension as shown below Will PASS
mac:tmp shivdev$ sed -i “” “s/Apr/May/g” x.log
The reason that it works fine on Ubuntu but not on MacOS is that it uses a BSD sed (not GNU sed like Ubuntu)
-i extension
Edit files in-place, saving backups with the specified extension.
If a zero-length extension is given, no backup will be saved. It
is not recommended to give a zero-length extension when in-place
editing files, as you risk corruption or partial content in situ-
ations where disk space is exhausted, etc.
Category: Linux,Mac
Writing by shivdev on Tuesday, 14 of April , 2015 at 6:32 am
I’m so used to iTerm now and really need word navigation. (I do miss Windows some of the time)
Well Meta Key to the rescue. Great article by Serge Émond. But, in a nutshell…
Esc + f (Move forward one word)
Esc + b (Move back one word)
Esc + d (Delete word to the right)
Esc + delete (Delete word to the left)
Category: Mac
Writing by shivdev on Tuesday, 24 of March , 2015 at 5:32 am
AWS CLI to the rescue. It’s really quick and easy. Install AWS CLI, add your keys to the credentials and then fire away.
Here are some of mine
alias s3ls=’function _s3ls(){ aws s3 ls s3://”$@” ; }; _s3ls’
alias s3get=’function _s3get(){ aws s3 cp s3://”$@” . ; }; _s3get’
alias s3getdir=’function _s3getdir(){ aws s3 cp s3://”$@” . –recursive ; }; _s3getdir’
Category: Tips and Tricks
Writing by shivdev on Friday, 13 of March , 2015 at 7:48 pm
Pretty straightforward. If you don’t have a samba share here’s How to Create a Network Share Via Samba Via CLI (Command-line interface/Linux Terminal). So now you have a Samba Share on Linux.
Here’s a snippet of my /etc/samba/smb.conf that contains the Linux folder on my VM that I would like to access from the Mac. (In your Mac: it will show up under /Volumes/vm_codebase).
Of course you can ssh into your Linux env, but this is more like mounting onto your Mac.
[vm_codebase]
path = /home/shivdev/codebase
available = yes
valid users = shivdev
read only = no
browseable = yes
public = yes
writable = yes
From your Mac. Open Finder : Go –> Connect to Server… –> smb://vm –> Chose vm_codebase
Now you will see it under /Volumes/vm_codebase and is accessible like a regular folder.
Category: Linux,Mac
Writing by shivdev on Wednesday, 11 of March , 2015 at 4:11 am
I was trying a simple sed -i on my Mac and was running into
# Does NOT work on Mac
$ sed -i ‘s/^192.168.*vm/192.168.1.12 vm/’ /etc/hosts
sed: 1: “/etc/hosts”: extra characters at the end of h command
A quick google search resulted in stackoverflow getting sed error which has the solution. Apparently, Mac uses BSD sed and Linux uses GNU sed which have different set of arguments. So provide the extra argument in Mac as shown below.
# Adding the extra argument will work on your Mac
$ sed -i ” ‘s/^192.168.*vm/192.168.1.12 vm/’ /etc/hosts
Category: Linux,Mac
Writing by shivdev on Saturday, 28 of February , 2015 at 6:23 pm
If you want to see the full path to the currently open file on the title bar add “show_full_path”: true to the Settings JSON.
Sublime Text -> Preferences -> Settings – User
“show_full_path”: true
Category: Tips and Tricks