Hi Mick!

Am Mittwoch, 10. Februar 2016, 17:02:46 CET schrieb Mick:
> I've been struggling to parse/split/substitute some names and numbers using
> a spreadsheet and think that this task may be easier to achieve using
> conventional *nix tools. The problem is I wouldn't know where to start.

I was taught by other linux users (mostly fanatic KISS people from Archlinux 
:D) to use as less different tools and therefor dependencies for a script/
shell command as possible. In your case, simple bash might be even enough:

Check the bash man page for "PARAMETER EXPANSION" (these $
{foo...somethingspecial} instead of $foo).

> I have a directory with loads of images.  Each image file name has a
> description comprising hyphen-separated words and a part number, also hyphen
> separated; e.g.:

> some-description-with-words-012-63099.jpg
> 
> The number and length of the words change for each file.  The part number
> always has two components separated by a hyphen, but may also change in
> length and acquire more/fewer digits.
> 
> I need two outputs:
> 
> 1. the description + " (per M²)", like so:
> 
> some-description-with-words (per M²)

Just save both informations to one variable, then print/echo the value of 
these variables (something like "echo $VAR1 $VAR2" or even "echo $VAR1 (per 
M²)".

> 2. the part number, but replacing the hyphen with "/", like so:
> 
> 012/63099

Again, parameter substitution might work. :-)

> I can list the directory contents and redirect all image file names into a
> txt file.  What I am looking for is some additional steps I can pipe it
> through to obtain the two outputs, either in the same file or different
> files.  These file(s) are then imported into a spreadsheet template and
> manipulated, before the result is ultimately exported from the spreadsheet
> and uploaded to a server as a CSV file.
> 
> Is this parsing, splitting and substitution exercise achievable?  Any
> suggestions to try out?
"Everything is possible"™

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to