maletor
maletor

Reputation: 7122

Modify file in memory while keeping directory

Is there a way to modify the contents of a file before a command receives it while maintaining its directory?

mpv 'https://example.com/directory/file.playlist'

but use sed to modify the contents in memory before it is read by mpv?

The issue is I can't just read the file straight in, it must maintain the directory it is in because the files in the playlist are relative to that directory.

I just need to replace .wav with .flac.

Upvotes: 1

Views: 195

Answers (2)

maletor
maletor

Reputation: 7122

So far I'm using this to achieve what I need, but it's not exactly ideal in that I lose my playlist control.

ssh example.com "tar czpf - 'files/super awesome music directory'" | tar xzpf - -O | mpv -

Upvotes: 0

hek2mgl
hek2mgl

Reputation: 158180

Generally you can use process substitution:

mplayer <(curl 'http://...' | sed 's/\.wav/.flac/')

However, mplayer supports the special option - (hyphen) for the filename argument which means read the file from stdin. This allows you to use a pipe:

curl 'http://...' | sed 's/\.wav/.flac/' | mplayer -

Upvotes: 1

Related Questions