Submitted scripts and programs
Forum rules
Your own work only.
-
dkeg
- Configurator
- Posts: 3782
- Joined: Sun Nov 18, 2012 9:23 pm
- Location: Mid-Atlantic Grill
Unread post
by dkeg » Fri Feb 07, 2014 2:30 pm
I used this to bang in a line of text + blank line into multiple files. this is an *improved* version of the post from /dev/null.
Code: Select all
#! /bin/bash
FILES=/path/to/directory/*
for f in $FILES
do
sed -s -i -e '1i Text Here' -e '1i\\' $f
done
Work hard; Complain less
-
rhowaldt
- Dog
- Posts: 4565
- Joined: Wed Oct 17, 2012 9:01 am
-
Contact:
Unread post
by rhowaldt » Fri Feb 07, 2014 2:40 pm
i like insertion.
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
-
dkeg
- Configurator
- Posts: 3782
- Joined: Sun Nov 18, 2012 9:23 pm
- Location: Mid-Atlantic Grill
Unread post
by dkeg » Fri Feb 07, 2014 9:40 pm
thanks rho, even if you're speaking not of my script.
Work hard; Complain less
-
dkeg
- Configurator
- Posts: 3782
- Joined: Sun Nov 18, 2012 9:23 pm
- Location: Mid-Atlantic Grill
Unread post
by dkeg » Sun Feb 09, 2014 1:28 pm
I altered a bit to be more flexible.
place in /usr/local/bin
use:
Code: Select all
# insertion by dkeg
# 2014
#
#! /bin/bash
FILES='$@'
for f in $FILES
do
sed -s -i -e '1i Text Here' -e '1i\\' $@
done && exit 0
Work hard; Complain less
-
machinebacon
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
-
Contact:
Unread post
by machinebacon » Sun Feb 09, 2014 3:47 pm
May I recommend to put these thing in /usr/local/bin? Works the same way, and prevents chaos if ever a package named insertion will be downloaded :)
..gnutella..
-
dkeg
- Configurator
- Posts: 3782
- Joined: Sun Nov 18, 2012 9:23 pm
- Location: Mid-Atlantic Grill
Unread post
by dkeg » Sun Feb 09, 2014 4:09 pm
Thank you, duly noted and changed above
Work hard; Complain less