For When You Can't Have The Real Thing
[ start | index | login ]
start > Linux > prefix

prefix

Created by dave. Last edited by dave, 9 years and 163 days ago. Viewed 2,070 times. #2
[diff] [history] [edit] [rdf]
labels
attachments
(2014-11-10)

Problem

I want to prefix stdout lines with something that identifies it.

Solution

script named prefix

#!/bin/bash
cat | sed -u 's/^/['"${1%}"'] /'

Usage:

$ for i in one two three ; do ssh $i cat /etc/resolv.conf | prefix $i ; done

(>>Source)

no comments | post comment
This is a collection of techical information, much of it learned the hard way. Consider it a lab book or a /info directory. I doubt much of it will be of use to anyone else.

Useful:


snipsnap.org | Copyright 2000-2002 Matthias L. Jugel and Stephan J. Schmidt