You are not logged in.

#1 2009-12-27 19:51:56

jon.wulf
Member
Registered: 2009-07-03
Posts: 40

Shell scritping help

Hello all,

I wasn't sure where to put this so if it needs moving, mods please feel free to do so.

I'm trying to write a shell script and have hit a dead end. Despite googling everything I can think of I have come up short. I'm trying to create a script to take a text file and process it for me. By this I mean, copy lines with certain data, remove any spaces or tabs and trim out extra garbage. It's the last step I am stuck with...

I need to find a way to copy a string of text that varies to a new file, I'm working with web addresses to get that out in the open. Ideally I need a command or sequence of them to take a string starting with http and ending with .jpg (I'll adapt for other extensions later) and place all the excerpts from the file into a fresh one ready for passing through wget.

Any help or pointers is much appreciated,

Thanks in advance,

Jon

Offline

#2 2009-12-27 20:03:21

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,422
Website

Re: Shell scritping help

research sed


.:[My Blog] || [My GitHub]:.

Offline

#3 2009-12-27 20:06:55

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Shell scritping help

Getting all of a certain kind of string is easier with grep -o than sed because of multiple hits per line, e.g. grep -o 'http[^ ]*jpg' file.html

Offline

#4 2009-12-27 20:09:04

jon.wulf
Member
Registered: 2009-07-03
Posts: 40

Re: Shell scritping help

Thanks Procyon that's exactly what i was searching for. big_smile

Jon

Offline

Board footer

Powered by FluxBB