Piped together grep ?: Rails Tutorial Notes--Chapter 8

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"

Exercise content

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?

| (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.)

Try using

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

Piped together grep ?: Rails Tutorial Notes--Chapter 8
11.1 AccountActivations Resources: Rails Tutorial Notes-Chapter 11
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
rails tutorial
Testing for Error Messages: Rails Tutorial Notes-Chapter 7
11.2 Send Account Activation Email: Rails Tutorial Notes--Chapter 11
rails tutorial Chapter 6
Rails tutorial test
rails tutorial Chapter 1
Rails tutorial memorandum 1
Rails tutorial memorandum 2
rails tutorial Chapter 7
rails tutorial Chapter 5
rails tutorial Chapter 10
rails tutorial Chapter 9
rails tutorial Chapter 8
Start Rails Tutorial
[Beginner] Rails Tutorial
I changed the way Rails tutorials run: Rails Tutorial Notes-Chapter 9
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Rails Tutorial cheat sheet
Rails Tutorial Chapter 3 Learning
[Rails] Learning with Rails tutorial
Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 4 Learning
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Chapter 8 Notes
rails tutorial fighting notes Ⅲ
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
Rails Tutorial Records and Memorandum # 0
Rails Tutorial (4th Edition) Summary
[Rails Tutorial Chapter 4] Rails-flavored Ruby
[Rails] Implementation of tutorial function