Skip to content

Instantly share code, notes, and snippets.

@sthesing
Last active January 4, 2016 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sthesing/8558909 to your computer and use it in GitHub Desktop.
Save sthesing/8558909 to your computer and use it in GitHub Desktop.
Replace script for app.net's @nhk using sed.
#!/bin/bash
#Cut extension off
FILENAME=`echo $1 | cut -d'.' -f1`
#Put [$FILENAME][S. ] before everything in double quotes
sed -i 's|\(\".*\"\)|['$FILENAME'][S. ]\1|g' $1
@sthesing
Copy link
Author

You have a file foo.txt with the following content:

Test
"bar"
Test2

If you run ./nhk_replace.sh foo.txt, the script replaces the content with:

Test
[foo][S. ] "bar"
Test2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment