LinuxQuestions.org
Help answer threads with 0 replies.
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 08-29-2003, 01:33 AM   #1
karlis
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Rep: Reputation: 0
Post use file data in command lines


I was able to get the pid number of a particular process using
ps -e | grep xeyes | cut -f2 -d" " > m
and that would put the pid of xeyes into a file called m.
But I now want to be able to use this number, in say the kill function.
Can I write something like:
kill < m
(This doesn't work, but you get the idea)
Thanks.
 
Old 08-29-2003, 06:22 AM   #2
andrewlkho
Member
 
Registered: Jul 2003
Location: London
Posts: 548

Rep: Reputation: 31
um... I'm thinking of concatenating the file, and then using a variable, such as:
$NUM=cat m
kill $NUM
I'm not sure if this would work, but it's worth a try.
 
Old 08-29-2003, 10:00 AM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Try this:

kill `cat m`

The back-ticks mean to replace the command inside with its output.
 
Old 08-29-2003, 07:27 PM   #4
slapNUT
Member
 
Registered: Jun 2001
Location: Recycle Bin
Distribution: Linux & Everything else on VirtualBox
Posts: 144

Rep: Reputation: 15
XEYES=`ps -e | grep xeyes | cut -f2 -d" " > m`
kill $XEYES

Use pidof instead, it's much easier;
XEYES=`pidof xeyes`
kill $XEYES

But all you really need to do is:
killall xeyes
or
kill `pidof xeyes`
 
  


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
Command erase lines paraiso Linux - Newbie 4 05-12-2005 10:48 AM
command to count how many lines in a file? dr_zayus69 Linux - Software 3 01-06-2005 10:42 AM
Combining 2 command lines satimis Programming 6 10-18-2004 09:40 PM
Executing command lines in C/C++ ReverseLogic Programming 2 05-28-2002 02:08 PM
command lines? rockin chair Linux - General 5 04-28-2002 10:48 PM

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

All times are GMT -5. The time now is 06:01 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