Add content on to the beginning of something (usually a file).
Questions tagged [prepend]
497 questions
4
votes
2 answers
Find text in a string and prependTo somewhere else
I am trying to find some text RegEx /\w*http:[/][/]bit.ly[/]\w*/ig that will find this string and pull it out, moving it to the tag, or at the end of the
tag?
Text before http://bit.ly/wtGAhsu sometext here, doesn't…

James
- 43
- 2
4
votes
1 answer
Using jq to add/prepend an element to the top of an array
I have the following json file (example.json):
{
"examples": [
{
"example": "2"
},
{
"example": "3"
}
]
}
I'd like to use jq to add a new element to the top of this array (rather than the bottom). All the solutions…

keeer
- 783
- 1
- 5
- 11
4
votes
2 answers
How to prepend a file using fish
I saw there were several good answers for bash and even zsh(i.e. Here). Although I wasn't able to find a good one for fish.
Is there a canonical or clean one to prepend a string or a couple of lines into an existing file (in place)? Similar to what…

Paiusco
- 305
- 1
- 14
4
votes
4 answers
React prepend item to list
I'm trying to prepend an item to a list:
addPersonHandler = () => {
const newPerson = {
id: "new",
edit: true,
name: "",
dni: "",
onDelete: this.discardHandler
};
// I want…

danielrvt
- 10,177
- 20
- 80
- 121
4
votes
1 answer
Need help with: jquery prepend doctype to html
Here's my situation:
I am editing an application's CSS style sheet.
I can ONLY edit the CSS style sheet (unless I can creatively glom onto another file using the CSS, or possibly add a small jQuery prepend statement in an existing .js)
Application…

caroline
- 421
- 2
- 5
- 12
4
votes
5 answers
Prepend a string in Python
I'm trying to prepend zeros to each number in a list if it isn't a the necessary number of digits.
lst = ['1234','2345']
for x in lst:
while len(x) < 5:
x = '0' + x
print(lst)
Ideally this would print ['012345',…

Coby
- 136
- 1
- 2
- 8
4
votes
2 answers
What is the mechanism of using append to prepend in Go?
Suppose I have a slice slice of type int. While declaring, I set the third argument to size, which I believe reserves memory for at least size ints by setting the cap parameter of the slice.
slice:=make([]int,0,size)
Now, suppose I have an integer…

GoodDeeds
- 7,956
- 5
- 34
- 61
4
votes
3 answers
bash: How to prepend a string to stderr lines and combine both stdout and stderr in exact order and store in one variable in bash?
What I have done so far is :
#!/bin/bash
exec 2> >(sed 's/^/ERROR= /')
var=$(
sleep 1 ;
hostname ;
ifconfig | wc -l ;
ls /sfsd;
ls hasdh;
mkdir /tmp/asdasasd/asdasd/asdasd;
ls /tmp ;
)…

avg598
- 505
- 1
- 4
- 13
4
votes
1 answer
Stop prepend after first click
$('#home-btn').on('click', function(e) {
$('.settings-container').css('display', 'none');
$('.container').css('display', 'block');
$('.panel-heading').prepend(global_recipient);
});
So when i press the button (more than once), it…

heikaa
- 43
- 3
4
votes
4 answers
jQuery prepend to all hyperlink elements that link to PDF files
I would like to prepend "Download a PDF of " to any hyperlinks, linking to PDF files.
Currently I'm able to prepend that exact text, but it prepends it to the hyperlink text. I would like it to reside outside of the hyperlink element, like so:…

Hunter Satterwhite
- 41
- 1
- 2
4
votes
2 answers
Prepend to file without temp file by manipulating inode?
Prepending to a large file is difficult, since it requires pushing all
other characters forward. However, could it be done by manipulating
the inode as follows?:
Allocate a new block on disk and fill with your prepend data.
Tweak the inode to…
user354134
4
votes
2 answers
Jquery prepend click handler
If you know a better way to do this then please let me know.
Right I have a page which will contain lots of buttons, charts and tables.
I have read about stopping event propogation and that's what I'll be using.
I want to enable help on cerain…

John
- 106
- 2
- 13
3
votes
3 answers
Back-reference when preprend using sed linux command
I'm trying to prepend the first character of "monkey" using this command:
echo monkey | sed -E '/(.)onkey/i \1'
But when I use it like this, the output shows
1
monkey
I actually hope to see:
m
monkey
But back-reference doesn't work. Please…

Torprendido
- 33
- 5
3
votes
1 answer
Is there a file system with a low level prepend operation?
At the lowest levels most OS file operations include open, close, read, write, delete and seek and append operation, yet there is no prepend operation.
The question came up because a colleague of mine was working with a large (multi-gigabyte) data…

Great Turtle
- 3,315
- 7
- 32
- 36
3
votes
2 answers
Readarray with preppended or appended values in Bash
In Bash if I want to get a list of all available keyboard layouts but prepend my own keyboard layouts I can do:
readarray -t layouts < <(localectl list-x11-keymap-layouts)
layouts=("custom1" "custom2" "${kb_layouts[@]}")
If I want to append I can…

user5507535
- 1,580
- 1
- 18
- 39