The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Filtering an output (http://hintsforums.macworld.com/showthread.php?t=36626)

derekhed 03-17-2005 11:28 AM

Quote:

Originally Posted by Raven
Guess I'll look into it... That book may at least be a good reference so I understand onther posts you gusy put in !

You could start here

Raven 03-17-2005 12:43 PM

One thing I realized... It does filter out three levels... That I understood, but I realize now that I only need to take out the first two... and I don't know whot o mod the sed command you gave me to do only two...
Some more help please ? ;)

DaleCooper 03-17-2005 02:17 PM

Quote:

Originally Posted by Raven
One thing I realized... It does filter out three levels... That I understood, but I realize now that I only need to take out the first two... and I don't know whot o mod the sed command you gave me to do only two...
Some more help please ? ;)

you can adjust the level by modifying the number in curly brackets. If you want at most two levels to be deleted, write \{,1\} instead of \{,2\}.

If you are using GNU sed you can substitute the entire brackets part with \? which means zero or once. GNU sed is as far as I know not a standard part of Mac OS X but can be installed with fink.

chris

Raven 03-17-2005 02:51 PM

I actually found a way "around" this in my AS... Because I wanted to take out part of a path, an issue came up with the slashes in what I wanted to remove... a friend of mine, used to perl, told me that I could try to replace those with = signs... and it does work...
So what I did is, indstead of trying to remove the first two parts, I added variables... I have a part that will change form user to user, but that one they have to input at the begining of the screipt anyways... So, since I have that part as a string, and know the first part is always /Volumes/, it created a new variable containing both in the right order and then entered them in sed like this:

du -ch " & variable & " | col -b | sed 's=" & variable & "==' > ~/Desktop/ServerName.txt

variable = /Volumes/server_name_variable

And now I have my nice cleaned up output !
AS does have features that can be very usfull some times...

Thanks for all the help !


All times are GMT -5. The time now is 06:23 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.