sukhoy94 / linux-bash-cheatsheet

Cheatsheet of useful bash commands I'm using everyday

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linus bash CheatSheet

Table of Contents

  1. Copy All Files from One Folder to Another
  2. Listing Files
  3. Find a File by Its Filename in a Directory
  4. List files with it's filesize

Copy all files from one folder to another

cp -r /source_dir/* /destination_dir/

To copy also hidden files (like .env, .gitignore):

cp -r /source_dir/{*,.*} /destination_dir/

Listing files:

The ls command in Linux is used to list directory contents. You can sort the output of ls in various ways by using different options.

  1. By Modification Time (newest first):
ls -lt
  1. By Size (largest first):
ls -lS

Find a file by it's filename in a directory

Basic Syntax

find /path/to/directory -name "*part_of_name*"

1. Find files containing "log" in their names:

find /path/to/directory -name "*log*"

2. Excluding folders from search

find /path/to/directory -type f -name "index*" \
  -not -path "*/vendor/*" \
  -not -path "*/node_modules/*"

List files with it's filesize

ls -lh

About

Cheatsheet of useful bash commands I'm using everyday