LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to grep, cut, cat in a single command? (https://www.linuxquestions.org/questions/programming-9/how-to-grep-cut-cat-in-a-single-command-804205/)

dwarf007 04-26-2010 03:02 AM

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

druuna 04-26-2010 03:08 AM

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.

dwarf007 04-26-2010 04:12 AM

would like to check the path defined for "userlist_file" and perform cat on it.

colucix 04-26-2010 04:16 AM

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


dwarf007 04-26-2010 04:40 AM

Thanks a lot guys, it helps to solved my problem :)

grail 04-26-2010 05:27 AM

Please mark as SOLVED

dwarf007 04-27-2010 02:36 AM

Great, thanks for the info grail


All times are GMT -5. The time now is 10:39 AM.