LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2004, 05:40 PM   #1
Blardov
LQ Newbie
 
Registered: Mar 2004
Posts: 1

Rep: Reputation: 0
Question Need help getting started


Hello...I am new to this arena and would like some assistance if anyone could offer.

I need to figure out how to open a file and search for a certain string of characters and whatever may follow after that string endin with a ']'

I need to then take that string and do a rm on that string which is essentially a file. There could be multiple occurrences of these strings in the file which would require a delete (rm) for each one.

for example : search a log file looking for "/user/*" It finds something that is "/user/character/player"
I will then need to do a delete of a file named "/user/character/player.bic"

I am not sure if this would be a shell or perl script but would aprreciate someone to point me in the right direction. Once identified how it can be done, I have no problem find a book to show me how.

Thank You.
 
Old 03-10-2004, 05:57 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
That one would work with bash or ksh:
- - - - - - - - - - - -
#!/bin/bash
for file in $(grep "/user/" $0 | sed -e 's/.*\/user\//\/user\/' -e 's/].*$//')
do
echo rm $file.bic
done
- - - - - - - - - - - -

remove the echo once you are confortable with the script ... !
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Started mattp Linux - Laptop and Netbook 6 01-08-2005 11:51 PM
Getting started k06878 Linux - Newbie 12 11-19-2004 08:42 AM
Getting Started burningtheory Linux - Distributions 2 09-07-2004 03:32 PM
Help Getting started reddog64 Linux - Newbie 9 04-18-2004 10:45 PM
Getting started.... noclue_menew Linux - Newbie 31 10-03-2003 01:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:41 PM.

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