Questions tagged [substitution]

The action of replacing something with another thing.

The action of replacing something with another thing.

1879 questions
8
votes
3 answers

Suppress C Macro Variable Substitution

I have this bit of code (part of an interpreter for a garbage-collected Forth system, actually): #define PRIMITIVE(name) \ do \ { \ VocabEntry* entry = (VocabEntry*)gc_alloc(sizeof(VocabEntry)); \ entry->code = name; \ …
feralin
  • 3,268
  • 3
  • 21
  • 37
8
votes
4 answers

Bash double process substitution gives bad file descriptor

When I try to refer to two process substitution pipes in a bash function, only the first one referenced works. The second one gives a "bad file descriptor" error like so: $ foo(){ > cat "$1" > cat "$2" > } $ foo <(echo hi) <(echo bye) hi cat:…
rharder
  • 348
  • 2
  • 8
7
votes
3 answers

Prepend file names with plus sign

I want to add a + (plus sign) before all the occurrences of image names in a huge file, using sed. This is an example of one line: DAUSSI-H22-14K White Gold-Princess-1.00ct-G-SI1orH-VS2-EGL-mm-3.5,,H22,,7050,5720,3/5/2012…
OSdave
  • 8,538
  • 7
  • 45
  • 60
7
votes
2 answers

Vim alter text as or immediately after it's put

Lately I've been yanking and putting a lot of code that needs to be altered somewhat (usually just a simple substitution). I can manually select it after it's pasted in, or for longer blocks I suppose I could look at the number of lines pasted (20…
Kevin
  • 53,822
  • 15
  • 101
  • 132
7
votes
3 answers

How do I SELECT WHERE IN VALUES with tuples in Python sqlite3?

I have an SQLite database with three columns, and I'm trying to use parameter substitution for tuples to SELECT rows. This is my table: conn = sqlite3.connect("SomeDb.sqlite3") conn.execute(""" CREATE TABLE RoadSegmentDistribution( Source…
jmkjaer
  • 1,019
  • 2
  • 12
  • 29
7
votes
2 answers

Remove blank lines in a file using sed

France 211 55 Europe Japan 144 120 Asia Germany 96 61 Europe England 94 56 Europe Taiwan 55 144 Asia North Korea 44 2134 Asia The above is my data file. There are empty lines in it. There are no spaces or tabs in those empty…
7
votes
2 answers

How do I create a "macro" for regressors in R?

For long and repeating models I want to create a "macro" (so called in Stata and there accomplished with global var1 var2 ...) which contains the regressors of the model formula. For example from library(car) lm(income ~ education + prestige, data…
jay.sf
  • 60,139
  • 8
  • 53
  • 110
7
votes
6 answers

awk dynamic document indexing

I have a document that I need to dynamically create/update the indexes in. I am trying to acomplish this with awk. I have a partial working example but now I'm stumped. The example document is as follows. numbers.txt: #) Title #) Title …
Datavar
  • 71
  • 2
7
votes
1 answer

Bash variable substitution on find's output through exec

Is there any way to apply Bash variable substitution on find's output? I know I've seen someone do it on Stack Overflow but I can't seem to find that particular post anymore. As an example, let's say I want to rename files ending in *.png to…
ShellFish
  • 4,351
  • 1
  • 20
  • 33
7
votes
2 answers