LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-01-2017, 01:43 PM   #1
patpat2
LQ Newbie
 
Registered: Apr 2017
Posts: 1

Rep: Reputation: Disabled
using grep with echo command


Is there a way to use a grep command with an echo command so that the output will show only part of what is being echoed?
 
Old 04-01-2017, 02:24 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,306
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
Welcome.

The short answer is yes. You probably don't need echo at all, but can you clarify more precisely what you mean? Also show what you have tried so far so we have a better idea of both what you want and where you are along the way there.
 
Old 04-02-2017, 03:39 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
read
Code:
man grep
maybe it's enough to answer your question.
 
Old 04-02-2017, 06:31 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
I use an alias to colorize my grep results/hits.
If that sounds like what you'd like stick this in your ~/.bashrc
Code:
alias grep="grep --color=auto -i"
 
Old 04-02-2017, 07:48 PM   #5
Azat
LQ Newbie
 
Registered: Apr 2017
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by patpat2 View Post
Is there a way to use a grep command with an echo command so that the output will show only part of what is being echoed?
Can you be more specific?

If you use grep -o it will echo that pattern only and not the entire line.

For example

echo "My name is Azat, I love linux" | grep -o linux
linux

This will return the pattern linux and ignore the rest.

Last edited by Azat; 04-02-2017 at 10:01 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] echo 8888|grep 8+ does not match. stf92 Linux - Newbie 3 07-30-2015 03:54 PM
grep | xargs -I echo $(foo; bar; echo $(fee; fi; fo; fum)) == questionable output.. GrapefruiTgirl Programming 11 12-07-2010 07:02 PM
echo and grep s_linux SUSE / openSUSE 3 06-16-2010 08:17 PM
Grep with Echo Myiagros Linux - General 3 04-26-2010 10:12 AM
Problems with grep when used with echo pavan_pnv Linux - Newbie 3 03-18-2008 06:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration