Sponsored Content
Top Forums Shell Programming and Scripting Isolate text with sed or similar utility Post 302955751 by ejianu on Monday 21st of September 2015 09:44:53 AM
Old 09-21-2015
Isolate text with sed or similar utility

All,

I'm getting a list like the following and I'd like to kill each PID in turn.

Code:
        pid (17797)
        pid (21748)
        pid (21754)
        pid (21704)
        pid (2199)
        pid (2159)
        pid (17809)
        pid (21769)
        pid (21778)
        pid (21715)
        pid (2211)
        pid (2171)

How can I isolate the PID in ksh with sed or other utility?
Thank you!

Last edited by Scrutinizer; 09-21-2015 at 12:14 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sed utility

Hi, Can you explain little bit with example regarding SED utility in UNIX? How iit is different then grep command? Thanks in advance. Malay (4 Replies)
Discussion started by: malaymaru
4 Replies

2. Shell Programming and Scripting

Sed utility

I am new to unix os. Can you explain in short about sed? with some examples. (1 Reply)
Discussion started by: Padmav
1 Replies

3. UNIX for Dummies Questions & Answers

Appending text to a number of similar filenames

Hi, I was wondering if there was a way to append something to filenames based on a wildcard. For example, if I have the following files in a directory: blah1 blah2 blah3 blah4 blah5 I want to rename these all to: blah1.txt blah2.txt blah3.txt blah4.txt blah5.txt Is there a... (4 Replies)
Discussion started by: Djaunl
4 Replies

4. UNIX and Linux Applications

Free-text retrieval utility

Can anyone recommend an free-text retrieval utility? Open source or free preferred. Any views on say IQ-text? (0 Replies)
Discussion started by: MJDRM
0 Replies

5. UNIX for Dummies Questions & Answers

sed to isolate file paths separated by a pattern

Hi, I've been searching for a quick way to do this with sed, but to no avail. I have a file containing a long series of (windows) file paths that are separated by the pattern '@'. I would like to extract each file path so that I can later assign a variable to each path. Here is the file:... (2 Replies)
Discussion started by: nixjennings
2 Replies

6. Homework & Coursework Questions

script similar to rm utility

1. The problem statement, all variables and given/known data: saferm is a replacement for the rm utility. Rather than removing files, it move files in a sub directoy called".saferm" in the user's home directory. If "~/.saferm" doesn't exist, it is automatically created. The -l options lists the ... (3 Replies)
Discussion started by: Joey12
3 Replies

7. Shell Programming and Scripting

Grep to isolate a text file line and Awk to select a word?

I am looking at using grep to locate the line in the text file and them use awk to select a word or words out of it. I know awk needs -v to allow a variable to be used, but also needs -F to allow the break up of the sentence and allow the location of separate variables. $line = grep "1:" File |... (8 Replies)
Discussion started by: Ironguru
8 Replies

8. Shell Programming and Scripting

Reducing text file using similar lines

Hello, I am a java programmer but want to try unix for a purpose where I need to reduce a file using its first field.. Here is the sample data: admin;2;0;; admission;8;0;; aman;1;0;; caroline;0;4;; cook;0;4;; cook;2;0;; far;0;3;; far;1;5;; I am explaining the dataset first. There... (5 Replies)
Discussion started by: shekhar2010us
5 Replies

9. Shell Programming and Scripting

Editing files with sed or something similar

{ "AFafa": "FAFA","AFafa": "FAFA" "baseball":"soccer","wrestling":"dancing" "rhinos":"crocodiles","roles":"foodchain" } I need to insert a new line before the closing brackets "}" so that the final output looks like this: { "AFafa": "FAFA","AFafa": "FAFA"... (6 Replies)
Discussion started by: SkySmart
6 Replies

10. Answers to Frequently Asked Questions

Why Parsing Can't be Done With sed ( or similar tools)

Regularly we have questions like: i have an XML (C, C++, ...) file with this or that property and i want to extract the content of this or that tag (function, ...). How do i do it in sed? Yes, in some (very limited) cases this is possible, but in general this can't be done. That is: you can do... (0 Replies)
Discussion started by: bakunin
0 Replies
PIDFILE(3)						   BSD Library Functions Manual 						PIDFILE(3)

NAME
pidfile -- write a daemon pid file LIBRARY
System Utilities Library (libutil, -lutil) SYNOPSIS
#include <util.h> int pidfile(const char *path); DESCRIPTION
pidfile() creates a file containing the process ID of the caller program. The pid file can be used as a quick reference if the process needs to be sent a signal. When the program exits, the pid file is removed automatically, unless the program receives a fatal signal. If path is NULL or a plain basename (a name containing no directory components), the pid file is created in the /var/run directory. The file name has the form /var/run/basename.pid. The basename part is either the value of path if it was not NULL, or the program name as returned by getprogname(3) otherwise. If path is an absolute or relative path (i.e. it contains the '/' character), the pid file is created in the provided location. Note that only the first invocation of pidfile() causes a pid file to be written; subsequent invocations have no effect unless a new path is supplied. If called with a new path, pidfile() will remove the old pid file and write the new one. RETURN VALUES
pidfile() returns 0 on success and -1 on failure. SEE ALSO
atexit(3) HISTORY
The pidfile() function call appeared in NetBSD 1.5. Support for creating pid files in any arbitrary path was added in NetBSD 6.0. BUGS
pidfile() uses atexit(3) to ensure the pid file is unlinked at program exit. However, programs that use the _exit(2) function (for example, in signal handlers) will not trigger this behaviour. BSD
March 23, 2011 BSD
All times are GMT -4. The time now is 10:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy