A memo so that you can look back on what you searched for in 3 minutes
Connect commands with the pipe function? Grep? The point was that it was kindly written as "terminal"
By using the pipe function of the terminal to connect the execution result of rails routes and the grep command, you can display only the routes related to the Users resource. Similarly, let's display only the results for the Sessions resource. How many Sessions resources do you currently have? (Rails Tutorial 6th Edition 8.1.1)
|
(pipe)
I love it because it's easy to understand
Process to pass the output result of the command to the next
grep Linux commands to search and display strings in files using regular expressions (This time, I feel like I understand it.)
When you run rails routes
$ rails routes
Prefix Verb URI Pattern Controller#Action
root GET / static_pages#home
help GET /help(.:format) static_pages#help
about GET /about(.:format) static_pages#about
contact GET /contact(.:format) static_pages#contact
signup GET /signup(.:format) users#new
login GET /login(.:format) sessions#new
POST /login(.:format) sessions#create
logout DELETE /logout(.:format) sessions#destroy
.
.
.
I want to get only the lines containing "sessions" from here
rails routes | grep sessions
$ rails routes | grep sessions
login GET /login(.:format) sessions#new
POST /login(.:format) sessions#create
logout DELETE /logout(.:format) sessions#destroy
A little application (AND search)
rails routes | grep sessions | grep login
$ rails routes | grep sessions
login GET /login(.:format) sessions#new
POST /login(.:format) sessions#create
Recommended Posts