Wednesday, October 30, 2019

[Terminal] - Create file from the command line

If you need to create a file without content, just to test the write speed on USB Stick for example or SDCard, you can do it with this command:

mkfile -n 1000m no-content-1GB-file
1000m - the size of file  (value in mb)
no-content-1GB-file - the name of file  

Thursday, September 5, 2019

[SVN] - Commit files with @ character on filename

When you try to commit file on your SVN repository from command line and this file contains @ on filename and you get the error:
svn: E200009: 'your-file@2x.png': a peg revision is not allowed here
You just need to add the @ character to the end of file name you want to submit.

For example:

svn commit 'your-file@2x.png@'

Friday, August 16, 2019

[TERMIINAL] - Change character on filename to another one


Replace one character with another one on all files inside folder

for x in *"_"*; do mv -- "$x" "${x/_/-}"; done

On this example i need to change all _ to -


You can change the character to find on filename (orange color) and the replace character (red color) 

Friday, July 19, 2019

[TERMINAL] - How to go back to previous directory


If you want to return to the previous directory on terminal just one simple command you only need do:

cd -n


ex: 

Open termina, lock at the current folder and navigate to folder /usr/local. Now go back to previous directory
To do this you only need reproduce this steps:

open terminal and write:

1. pwd 
(get the current directory path)

2. cd /usr/local

3. cd -
(go back to previous directory)


Thursday, January 10, 2019

[MAC] - Read and Write NTFS drive

To write on NTFS USB disk on mac you need install third party apps. You have paid and free options. On this post will show how to install and use free application to read and write on NTFS drive on your mac.

Software needed:

xCode command line tools

If you haven’t installed them yet, you can open a Terminal and run the following command:
xcode-select --install

FUSE for macOS

Download FUSE for macOS and install it. Use the default options when installing it.

Brew

This is a package manager for Mac OS X. If you haven’t already installed it on your Mac paste this line on terminal. 

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

ntfs-3g

This is a driver to read and write NTFS drivers. To install paste this line on terminal. 

brew install ntfs-3g

Now you are able to read and write on NTFS partitions.

To mount NTFS you this following this steps:
1. Create folder to mapping drive. On terminal paste the above line:
sudo mkdir /Volumes/ntfs-storage
2. List all disks connected on your machine
diskutil list

3. Identify the device name and partition you want mount. On the screenshot you can see my disk is disk2s5 

4. Unmount selected partition with this command
sudo umount /dev/disk2s5

5. Finally, mount driver with this command. Don't forget to replace /dev/disk2s5 with your partition name
sudo /usr/local/bin/ntfs-3g /dev/disk2s5 /Volumes/ntfs-storage -olocal -oallow_other

ERRORS

If you got the error `Failed to mount '/dev/disk2s5' : Input/output error`

replace /dev/disk2s5 to your drive name (see here why you identify your disk mount name)
You need to run the command:



sudo ntfsfix /dev/disk2s5

After this command you should expect the following output:

sudo ntfsfix /dev/disk2s5
Mounting volume... $MFTMirr does not match $MFT (record 24).
FAILED
Attempting to correct errors... 
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... FAILED
Correcting differences in $MFTMirr record 24...OK
Correcting differences in $MFTMirr record 25...OK
Correcting differences in $MFTMirr record 26...OK
Correcting differences in $MFTMirr record 27...OK
Correcting differences in $MFTMirr record 28...OK
Correcting differences in $MFTMirr record 29...OK
Correcting differences in $MFTMirr record 30...OK
Correcting differences in $MFTMirr record 31...OK
Correcting differences in $MFTMirr record 32...OK
Correcting differences in $MFTMirr record 33...OK
Correcting differences in $MFTMirr record 34...OK
Correcting differences in $MFTMirr record 35...OK
Correcting differences in $MFTMirr record 36...OK
Correcting differences in $MFTMirr record 37...OK
Correcting differences in $MFTMirr record 38...OK
Correcting differences in $MFTMirr record 39...OK
Correcting differences in $MFTMirr record 40...OK
Correcting differences in $MFTMirr record 41...OK
Correcting differences in $MFTMirr record 42...OK
Correcting differences in $MFTMirr record 43...OK
Correcting differences in $MFTMirr record 44...OK
Correcting differences in $MFTMirr record 45...OK
Correcting differences in $MFTMirr record 46...OK
Correcting differences in $MFTMirr record 47...OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/disk2s5 was processed successfully.