LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2010, 03:02 AM   #1
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Rep: Reputation: 30
How to grep, cut, cat in a single command?


Would like to know how to cat the below output.

Code:
grep userlist_file /etc/vsftpd/vsftpd.conf | cut -c15-
Below which is the output for above command.
/etc/vsftpd/ftpusers
 
Old 04-26-2010, 03:08 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I'm not sure what it is you are asking.

The command you show will look for a line containing userlist_file in the file called /etc/vsftpd/vsftpd.conf, the cut command shows all from char 15 and on.

Depending on what is inside /etc/vsftpd/vsftpd.conf the output shown (/etc/vsftpd/ftpusers) could or could not be correct/what you want.

Please tell a bit more what it is you want to achieve.
 
Old 04-26-2010, 04:12 AM   #3
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Original Poster
Rep: Reputation: 30
would like to check the path defined for "userlist_file" and perform cat on it.
 
Old 04-26-2010, 04:16 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Maybe you need to assign it to a variable using command substitution, so that you can use its value in subsequent commands, e.g.
Code:
my_file=$(grep userlist_file /etc/vsftpd/vsftpd.conf | cut -c15-)
echo "userlist_file is $my_file"
if [ -f "$my_file" ]
then
  echo file exists
else
  echo file not found
fi
 
Old 04-26-2010, 04:40 AM   #5
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Original Poster
Rep: Reputation: 30
Thanks a lot guys, it helps to solved my problem
 
Old 04-26-2010, 05:27 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
Please mark as SOLVED
 
Old 04-27-2010, 02:36 AM   #7
dwarf007
Member
 
Registered: Sep 2004
Location: Malaysia
Posts: 181

Original Poster
Rep: Reputation: 30
Great, thanks for the info grail
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help with cut command using find. Cut last 8 characters leaving the rest ncsuapex Programming 4 09-16-2009 08:55 PM
How to use command grep,cut,awk to cut a data from a file? hocheetiong Linux - Newbie 7 09-11-2008 07:16 PM
grep and cut command tanveer Linux - General 3 09-05-2008 02:17 AM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 04:16 AM
'cat' not allowing absolute filenames when piped to 'cut' d3funct Programming 6 12-06-2002 02:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:18 PM.

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