From owner-freebsd-questions Fri Mar 10 8:10:19 2000 Delivered-To: freebsd-questions@freebsd.org Received: from fremont.bolingbroke.com (adsl-216-102-90-210.dsl.snfc21.pacbell.net [216.102.90.210]) by hub.freebsd.org (Postfix) with ESMTP id 0398237BBAB for ; Fri, 10 Mar 2000 08:10:14 -0800 (PST) (envelope-from ken@bolingbroke.com) Received: from fremont.bolingbroke.com (fremont.bolingbroke.com [216.102.90.210]) by fremont.bolingbroke.com (Pro-8.9.3/Pro-8.9.3) with ESMTP id IAA66263; Fri, 10 Mar 2000 08:10:09 -0800 (PST) Date: Fri, 10 Mar 2000 08:10:09 -0800 (PST) From: Ken Bolingbroke To: freebsd-questions@FreeBSD.ORG Cc: Jonathan Wall Subject: Re: truncating lines with a script... In-Reply-To: <934E0337010C01E0@smtp-gate.mottmac.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Assuming you want to truncate the ':1' too: {generate output} | sed -e 's/Xvnc :1 .*/Xvnc/' Or if you want to keep the ':1' (I'm not clear on that part): {generate output} | sed -e 's/Xvnc :1 .*/Xvnc :1/' Ken Bolingbroke hacker@bolingbroke.com On Fri, 10 Mar 2000, Jonathan Wall wrote: > I have a very simple sh script that runs 'ps' via rsh for some machines on > our network and then pipes the output through grep to pick out the lines of > interest - in this case the Xvnc processes. I would like to then pipe the > output through another command to remove the superfluous Xvnc command line > switches the ps command also shows. > > The script as it currently stands is shown below. I thought sed would be > the answer but apart from having an astoundingly cryptic man page, I think > it can only delete whole lines containing a particular string rather than a > segment of a line. I know I could have used 'comm' instead of 'command' in > the script to have a shortened output from ps, but then I can't see which > screen the Xvnc processes are attached to. The typical output is below the > script and given this example I would ideally like to remove everything > after the ':1'. Perhaps I should be using awk or perl ??? > > 1:27 Xvnc :1 -desktop X -httpd /usr/personal/jw1/apps/share/vnc/classes > -auth /usr/personal/jw1/.Xauthority -geometry 1024x768 -depth 16 -rfbwait > 120000 -rfbauth /usr/personal/jw1/.vnc/passwd -rfbport 5901 -fp > /usr/lib/X11/fonts/misc/,/usr/lib/X11/fonts/75dpi/,/usr/lib/X11/fonts/100dpi > /,/usr/lib/X11/fonts/decwin/75dpi/,/usr/lib/X11/fonts/decwin/100dpi/,/usr/li > b/X11/fonts/cde/75dpi/,/usr/lib/X11/fonts/cde/100dpi/,/usr/lib/X11/fonts/use > r/75dpi/,/usr/lib/X11/fonts/user/100dpi/,/usr/lib/X11/fonts/user/misc/,/usr/ > lib/X11/fonts/Speedo/,/usr/lib/X11/fonts/Type1/,/usr/lib/X11/fonts/Type1Adob > e/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message