megacolorboy

Abdush Shakoor's Weblog

Writings, experiments & ideas.

Rename extensions of multiple files

In this example, we're going to change a list of .txt files to .md files:

#!/bin/bash

shopt -s nullglob
files=($(ls -v *.txt))

for file in "${files[@]}"
do
    mv ${file} ${file}.md
done

s You can use modify this script to rename any extension you want.

Create a symbolic storage link

When using Laravel, the public directory is used for files that are publicly accessible. By default, it's stored in local and often stored in this storage/app/public directory. You can make it easily accessible by using the following command:

php artisan storage:link

Once, it has been created, you can use access those files using the public_path or asset methods.

<?php
echo public_path('images/sample_1.jpg');
echo asset('images/sample_2.jpg');
?>

Including and excluding files in zip

When zipping a directory or a bunch of files, there'll be a lot of stuff that you want to include and exclude.

To exclude a file:

zip -r files.zip . -x file_1 file_2

Alternatively, you can choose to include files:

zip -r files.zip . -i file_1 file_2

Find a file by extension

This comes in handy whenever I want to look for files that exists with a specific extension in a computer or server:

find . -name "*.ext"

In addition, sometimes, you might want to look for a bunch of files with a specific extension but with matching keywords:

find .name "*.ext" | grep "keyword"

Hope you found this helpful!

Check branch status

Ever wondered if you've edited or committed anything in your project before pushing it to your repository, do this:

git status

Enable spellcheck

This can be useful when you're writing stuff, just do the following:

:set spellcheck=[lang]

View hardware info

Want to check the specs of your system? Just type this:

lshw

Too long? Then type this for a shorter version:

lshw -short

Quit VIM

One of the most infamous issues that new users of VIM faces when using it for the first time. Press :q to quit VIM

If you've worked on a file and want to save and quit? Just type :wq!.

I hope that solved your quitting issue with VIM.