Computing.Net > Forums > Unix > Is it possible ?

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Is it possible ?

Reply to Message Icon

Original Message
Name: aka
Date: August 30, 2005 at 15:10:32 Pacific
Subject: Is it possible ?
OS: WinXP/Linux
CPU/Ram: 256
Comment:

My idea is to create an alias or command who runs this:

grep -A32 -B9 (text) (file)

So it will bring me 32 lines AFTER the text I grep and 9 lines BEFORE
the grep search on the file xxxxxx

Now, the idea is to create an alias (or command) with the name
"gime" who execute the command above, so I only need to write:

%:gime (text)

Can I specify it as an alias or need it be a command, if so, how can i create it
on bash

Something like this ?

#!/usr/local/bin/bash

grep -A32 -B9 $1 myfile

And save it as "gime" ?

Thanks a lot for your help.

Don´t freak out until you know the facts...Relax...!


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: September 1, 2005 at 09:36:19 Pacific
Reply:

Place this into a file called "gime" and change the permissions to execute:

#!/usr/local/bin/bash

grep -A32 -B9 "$*" myfile

Execute it as such:

gime my text

and you'll get 9 lines before and 32 lines after of line with the words "my text" in it. It's unclear whether you want to keep the line that's matched. If you don't want the line, change the grep command above to:

grep -A4 -B3 "$*" myfile|sed "/$*/d"


Report Offensive Follow Up For Removal

Response Number 2
Name: nails
Date: September 1, 2005 at 09:42:15 Pacific
Reply:

Let me repost my example. Sorry for any confusions:

Place this into a file called "gime" and change the permissions to execute:
#!/usr/local/bin/bash

grep -A32 -B9 "$*" myfile

Execute it as such:

gime my text

and you'll get 9 lines before and 32 lines after of line with the words "my text" in it. It's unclear whether you want to keep the line that's matched. If you don't want the line, change the grep command above to:

grep -A32 -B9 "$*" myfile|sed "/$*/d"



Report Offensive Follow Up For Removal

Response Number 3
Name: aka
Date: September 2, 2005 at 10:55:08 Pacific
Reply:


Thanks a lot nails

It works..its aliiiiiiiiive


jejeje :þ

Thanks again, seriously.

Don´t freak out until you know the facts...Relax...!


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home



Results for: Is it possible ?

is it possible when using exec with
    Summary: is it possible when using exec within a script, for the script not to exit? i have an exec command and more commands after it that cant run because exec exits ...
www.computing.net/answers/unix/is-it-possible-when-using-exec-with/7652.html

Is this possible with Cron
    Summary: Is it possible to start a process at a certain time (6:40) stop at (18:20) and cycle in between these times every 2 minutes ? In cron 20-40/2,40-00/2,00-20/2 6-18 14 12 * any/idea This would mess up t...
www.computing.net/answers/unix/is-this-possible-with-cron/7249.html

Is it possible to install Unix on a Wind
    Summary: No, but you can partion your disk (use tools like partion magic which lets you to partion your disk with data on it) then install Solaris (x86) on the other partion. I am not sure Solaris 8 x86 is ava...
www.computing.net/answers/unix/is-it-possible-to-install-unix-on-a-wind/1917.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software