[RAILS] [Linux] When you want to search for a specific character string from multiple files

Introduction

When I changed the column name in Rails, it was troublesome to find the column name before the change and fix it to the column name after the change, so I will write this article this time.

command

$ find ./ -type f -print | xargs grep 'hoge'

Description of the above command

find Search for files under the directory specified after find. The file search syntax is "find [path] [search condition] [action]"

./ The search target is under the current directory. If you enter "~ /", the search target will be under the home directory. You can use the full path instead of ./. In this case as well, the search target is under the specified directory.

-print Output search results as standard. At this time, the result is displayed with the full path.

-type f Search for the specified file type. If f is a normal file, c or d is a directory, and l is a symbolic link.

xargs Create a command line from standard input and run it

grep Search for a string in a file. Specify the character string you want to search after grep.

reference

http://kawatama.net/web/1141

Recommended Posts

[Linux] When you want to search for a specific character string from multiple files
When you want to plt.save in a for statement
What to do when you want to receive files from a Windows client remotely
When you want to sort a multidimensional list by multiple lines
When you want to replace multiple characters in a string without using regular expressions in python3 series
Memorandum Regular expression When there are multiple characters in the character string that you want to separate
When you want to play a game via Proxy
I want to split a character string with hiragana
[Django] A memorandum when you want to communicate asynchronously [Python3]
Search for large files on Linux from the command line
[Addition] A memo for dividing a character string containing multiple spaces
When you want to use python2.x on modern Gentoo Linux
When you want to hit a UNIX command on Python
Try to extract a character string from an image with Python3
How to extract the desired character string from a line 4 commands
I want to specify a file that is not a character string for logrotate, but is it impossible?
Gist repository to use when you want to try a little with ansible
When you want to replace a column with a missing value (NaN) column by column
When running a Python shell from Electron, pass multiple arguments to run Python.
[Python] If you want to draw a scatter plot of multiple clusters
How to write a string when there are multiple lines in python
[Question] I want to scrape a character string surrounded by unique tags!
# 5 [python3] Extract characters from a character string
When you want a long line break
[Python3] Code that can be used when you want to cut out an image in a specific size
Linux: Netplan configuration guide to see when you want to fix the IP address
How to create a function object from a string
If you want to create a Word Cloud.
When you want to update the chrome driver.
Python Note: When assigning a value to a string
How to remember when you forget a word
How to create a shortcut command for LINUX
I tried to generate a random character string
A story that failed when trying to remove the suffix from the string with rstrip
[Python] I want to use only index when looping a list with a for statement
How to list files under the specified directory in a list (multiple conditions / subdirectory search)
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
Software that saves the set character string to the clipboard when you click the [Python] button
When I searched for "as a Service" from AaaS to ZaaS, I saw various services.
Checks if there is a specific character string for all files under the directory that is Python and outputs the target line
"Stop committing Japanese files to git on Mac> <" For the time being, I wrote a script to search for incompatible Japanese files on Mac and Linux.
I want to embed a variable in a Python string
[Python] How to expand variables in a character string
When you want to filter with Django REST framework
How to create a local repository for Linux OS
Useful operation when you want to solve all problems in multiple programming languages with Codewars
When you want to quickly translate a C # sample into another language such as VB
How to quickly count the frequency of appearance of characters from a character string in Python?
Introducing "Sherlock", a CLI tool that allows you to search for user names across SNS
A site to see when you want to read a machine learning paper but it seems difficult
When a character string of a certain series is in the Key of the dictionary, the character string is converted to the Value of the dictionary.