A command to specify a file with a specific name in a directory with find and mv, cp, or gzip it (linux)

Personal notes

Approach the file with a specific name in the directory.

If you want to gzip all the .dat files named hoge in the current directory,

find . -name "hoge*.dat" -exec gzip -v '{}' \;

If you want to gzip hoge01.dat to hoge **. dat excluding hoge00.dat

find . -name "hoge*.dat" -not -name "*00*" -exec gzip -v '{}' \;

By the way, if you want to move

find . -name "hoge*.dat" -not -name "*00*" -exec mv '{}'Directory path name\;

It's easy to apply.

I used it as a reference ↓ Set complex search conditions with the find command

Recommended Posts

A command to specify a file with a specific name in a directory with find and mv, cp, or gzip it (linux)
Replace the directory name and the file name in the directory together with a Linux command.
Recursively get the Excel list in a specific folder with python and write it to Excel.
How to get a specific column name and index name in pandas DataFrame
Get the list in the S3 bucket with Python and search with a specific Key. Output the Key name, last update date, and count number to a file.
How to generate a QR code and barcode in Python and read it normally or in real time with OpenCV
[Introduction to Pandas] Read a csv file without a column name and give it a column name
I want to write an element to a file with numpy and check it.
Zip-compress any file with the [shell] command to create a file and delete the original file.
How to read a file in a different directory
How to pass args or environment variables with Makefile and make command on #Linux
Output a binary dump in binary and revert to a binary file
Apply conda's env to a specific directory with pyenv-vertualenv
[Linux] After connecting to DB with teraterm and typing Sqlplus command, until logging in to DB (oracle)
How to interactively draw a machine learning pipeline with scikit-learn and save it in HTML
How to display a specified line of a file or command result on Linux (sed, awk)
[Linux] Grep multiple gzip files in a directory at once
Command to list all files in order of file name
How to copy and paste command line content without mouse in bash on Linux or mac
Process the gzip file UNLOADed with Redshift with Python of Lambda, gzip it again and upload it to S3
Find the white Christmas rate by prefecture with Python and map it to a map of Japan
A story about what to do when a bad interpreter: Not such file or directory appears in Anaconda3 and how to investigate the cause.
Linux file and directory permissions
Make it possible to output a log to a file with go echo
Search the file name including the specified word and extension in the directory
Create a temporary file with django as a zip file and return it
How to make a command to read the configuration file with pyramid
How to specify a .py file to load at startup in IPython 0.13
How to output the output result of the Linux man command to a file
I want to create a pipfile and reflect it in docker
Create and return a CP932 CSV file for Excel with Chalice
Is it possible to build a loop structure with a person whose city name and mayor's name are confusing?
How to input a character string in Python and output it as it is or in the opposite direction.
[Note] How to deal with unicode error and No such file or directory (output table to excel file with pandas)
Upload data to s3 of aws with a command and update it, and delete the used data (on the way)