Linked Questions
13 questions linked to/from Unix command to prepend text to a file
4
votes
4
answers
8k
views
Add a new line of text at the top of a file in bash shell [duplicate]
I want to write a bash script that takes my file:
READ_ME.MD
two
three
four
and makes it
READ_ME.MD
one
two
three
four
There are a bunch of similar StackOverflow questions, but I tried their ...
1
vote
2
answers
1k
views
how to add content of text file to the beginning of file with cat [duplicate]
In bash script, if I do this:
cat infile >> outfile
the content of "infile" is added from the last line of "outfile".
infile:
foo
bar
outfile:
superfoo
superbar
after cat command:
superfoo
...
0
votes
2
answers
542
views
How to concatenate a string value at the head of a text file [duplicate]
Real nit picky Linux question.
I have a text file, call it userec. I also have a string variable 'var_a'.
I want to concatenate the string value, let just say it's 'howdy' to the top of the text file....
0
votes
0
answers
49
views
Adding a header paragraph to a file with bash script (and sed) [duplicate]
I have a basic bash script to generate a file conversion with pandoc.
After the file conversion I want to add a text header (jekyll darkmatter) before the first line.
#!/bin/bash
# Pattern #sed -i &...
780
votes
9
answers
1.4m
views
How to read a file into a variable in shell?
I want to read a file and save it in variable, but I need to keep the variable and not just print out the file.
How can I do this? I have written this script but it isn't quite what I needed:
#!/bin/...
22
votes
4
answers
14k
views
How do I use a new-line replacement in a BSD sed?
Greetings, how do I perform the following in BSD sed?
sed 's/ /\n/g'
From the man-page it states that \n will be treated literally within a replacement string, how do I avoid this behavior? Is there ...
4
votes
2
answers
2k
views
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 ...
0
votes
1
answer
1k
views
How to log deployments in Deployer?
I'm using Deployer and enjoy it.
One thing I haven't figured out how to do yet though is write a log file of my deployments.
I'm attempting to append the commit hash and date to revisions.txt:
task(...
2
votes
3
answers
473
views
unix prepend line to file without buffer/copy
I want this, the sed solution looks good, but when I tried it seems to create a huge temp file.
unix command to prepend text to a file
I have big sql file that is like 28 gigs, I dont have much ...
6
votes
2
answers
188
views
Rails describe HTML content source
I am looking for a gem or elegant way to setup system where I would be able to see where certain HTML content came from. I am working on a big project, and a lot of my times goes determining where a ...
1
vote
1
answer
378
views
Set autocommit=0 inside ssh command
I want to run a SSH command using a cron and I want to extent this cron by adding autocommit=0 So that auto commit is disabled.
How can I achieve this?
Command:
mysql dbname -u dbuser -p'password' ...
0
votes
1
answer
187
views
Perl simple one-liner used to add header to a file doesn't work when input file is empty
We have in code one-liner used to add header to file. It looks like
perl -pi -e 'print "name, function, group\n" if $. == 1' CSV_FILE_NAME
Everything is fine except when CSV_FILE_NAME is ...
0
votes
1
answer
153
views
How to import special-format data into Elasticsearch?
I have been given a 15 GB .txt file that is formatted like this:
{
"_score": 1.0,
"_index": "newsvit",
"_source": {
"content": " \u0641\...