Computing desk | ||
---|---|---|
< April 2 | << Mar | April | May >> | April 4 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
Hi. ubuntu linux. I have a file that looks like this:
2 23 9453
and I want to automatically create a file that looks like this:
foo "bar 2" baz foo "bar 23" baz foo "bar 9453" baz
(the actual file is thousands of lines long and I need to do this conversion hundreds of times). Can anyone suggest a way to do this using a bash script? I am currently defining an emacs macro but I want to automate it. thanks in advance, Robinh (talk) 01:34, 3 April 2017 (UTC)
sed -e 's/^\(.*\)$/ foo "bar \1"\n baz/'
\n
in to the replacement part in sed. Thanks! Robinh (talk) 02:01, 3 April 2017 (UTC)
sed 's/.*/foo "bar &"\ baz/'
while read n; do echo foo \"bar $n\"; echo baz; done
foo "bar thing" baz
2 23 9453
for a in $( cat ./list.txt ) ; do sed "s/thing/$a/g" < part.txt >> final.txt ; done
There is a way of getting a file into for
, but I can't remember what it is; however this will work. LongHairedFop (talk) 19:00, 3 April 2017 (UTC)
while IFS='' read -r n; do printf 'foo "bar %s"\nbar\n' "$n"; done
(Shouldn't make a difference as you are just taking in numbers. mapfile
with some array=("${array[@]/#/PREFIX}") array=("${array[@]/%/SUFFIX}")
can be fun too...) --Artoria2e5 contrib 00:28, 4 April 2017 (UTC)for good measure, gawk: gawk '{printf("foo \"bar %d\"\n",$0);print "baz";}' < file.txt
Asmrulz (talk) 20:42, 3 April 2017 (UTC)
speaking of emacs, this should be doable in elisp alone. Asmrulz (talk) 20:48, 3 April 2017 (UTC)
elisp only, works on the current buffer, outputs to a temp buffer called "output-(name of old buffer)", use at your own risk:
(global-set-key [f6] (lambda () (interactive) (let* ((k (current-buffer)) (m (concat "output-" (file-name-base (buffer-file-name k)))) (n (with-current-buffer k (widen) (buffer-string))) (o (split-string n "\n" t))) (with-output-to-temp-buffer m (mapc (lambda (a) (princ (concat "foo \"bar " a "\"\nbaz\n"))) o)))))
Asmrulz (talk) 22:12, 3 April 2017 (UTC)
Samsung phones, as with all Android phones, has a lock screen. They also have a second lock screen that appears after the lock screen has been on for a minute or so. What is the second lock screen called? For reference: I turned on notifications for the lock screen. If I am in the initial lock screen, I see them. Then, the phone locks a second time to the other screen and all it shows is a clock. There is an icon indicating that notifications are present, but the notifications are not shown. Looking for documentation is difficult because I don't know what the lock-lock screen is actually called. 209.149.113.5 (talk) 14:31, 3 April 2017 (UTC)
I can't remember if I installed Clementine or it was bundled with Ubuntu 16.04. Tried Google searching but i'm only getting instructions on how to install it. Thanks ツ Jenova20 (email) 20:25, 3 April 2017 (UTC)