Sublime Text SFTP Package Server Locations

Writing by on Thursday, 30 of June , 2016 at 6:59 am

Sublime Text SFTP is an amazing and very nifty package to update remote files. I’ve been using it for a while now and the location where the SFTP Server Location where the config settings to the hosts are stored.

Now it’s different for different versions, but if you’re on a Mac then you may want to Setup a Server and save the config under
~/Library/Application Support/Sublime Text 3/Packages/User/sftp_servers. Sublime Text will not be able to detect the servers if they’re not stored in that location. You may want to find the folder sftp_servers which can be in /Library or ~/Library.

Leave a comment

Category: Linux,Mac

Recover a corrupted gz

Writing by on Wednesday, 14 of October , 2015 at 7:13 am

Sometimes you might be able to salvage a corrupted gzip. Typically this trick always works on most log files.

$ gunzip corrupted.gz
gunzip: corrupted.gz: unexpected end of file
gunzip: corrupted.gz: uncompress failed

Use the -c option that outputs to console, but redirect to a new salvaged file. Then gzip the salvaged file to recover it.

$ gunzip -c corrupted.gz > salvaged
$ gzip salvaged

You can now delete the corrupted gz file and use the salvaged version.

Leave a comment

Category: Linux,Tips and Tricks

Concatenate several gz files into one using bash linux command line

Writing by on Tuesday, 22 of September , 2015 at 5:24 am

This will work if there is only one period followed by gz. (*.gz)
Loop over all the files and extract the filename. Then do the usual …

for f in *.gz; do export l=`echo $f | cut -d’.’ -f1` ; gunzip $f; cat $l >> big_file ; gzip $l; done

Leave a comment

Category: Linux

Adding characters to beginning or end of every line in a file

Writing by on Tuesday, 28 of July , 2015 at 10:34 pm

You can use awk:

awk ‘{print “Begin : ” $0 ” \”End\”.”}’ file.txt

Or you could use sed:

sed ‘s/^/ Begin : /g’ file.txt
sed ‘s/$/ “End”./g’ file.txt

Leave a comment

Category: Linux

Remove ^M characters from file

Writing by on Tuesday, 28 of July , 2015 at 10:27 pm

The key is to enter Ctrl+V+M (^M) to simulate this.

on_mac$ sed -i ” -e ‘s/^M//g’ filename
on_linux$ sed -i -e ‘s/^M//g’ filename

This can also be done in vi/vim, but may not work in Sublime Text type editors.

Leave a comment

Category: Linux

sed: 1: “x.log”: extra characters at the end of x command

Writing by 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.

Leave a comment

Category: Linux,Mac

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.