I need to run a command in a shell script to insert a line in a file, after it finds certain line. To add the line 'user = mysql' after the line [mysqld] in file /etc/my.cnf
I'm trying to insert a line using sed that has leading spaces before the text. Sed seems to be just dropping the spaces and only inserting the text. Any ideas what I'm missing?
Code:
NAM=rb134 sed -i.bak -e "$i host ${NAM} {" /etc/crap
Instead of inserting a line with 8 leading spaces inserts it with "host" at the beginning of the line. I tried
Code:
NAM=rb134 sed -i.bak -e "$i ^ host ${NAM} {" /etc/crap
I would like to insert prior to the word "three" all items from this second file with the following contents:
Code:
four three two one
Now my issue is, and I have been using both sed and awk currently, that after the second line of the new file is read there will of course now be 2 copies of the word "three" but I would like to only insert the final 2 words, ie "two" and "one" prior to only the first occurrence of the word "three" so final file will look like:
Code:
one two four
[code]....
So here there is now only one of each word from the second file joined to make the new file. For simple code I have tried something like the following:
Code:
while read line do awk -v n=$line '!f && /three/{print n;f++}1' file1 > tmp_file mv tmp_file file1 done < file2
Now this works but seems very clumsy to me. There is obviously a better sed and / or awk out there.
I have a script can process input text file and find out 3 values called positive, negative, neutral. Now, I have a new input file which contains some text called 'content' and I need to use the above script to get three value positive, negative, neutral for each of this 'content'. The content is text in many lines and bounded by two tags <content> and </content>
The input file could have this format:
<example> <input> <id>abcdef</id> <content> line1 line 2
[Code].....
Do you think that is possible to write that in Linux ? I have the feeling that using Linux with text finding, replacing much shorter and easier(when I have to write long and complicated code in other languages), so really want to learn how to use it from here.
i have two files with thousands of line, I am trying to combine these two files but i want to insert each line of one file to the another file after certain lines. I am using awk with the following command but it does not work.cat file1 | awk ' { print $0; if (NR%3004==0) {print "file2"}}' > outputfile
I am trying to create a shell script where a user can specify a file with a list of logins and the script will create a batch file with specific information in specific columns.
Example:
loginfile.txt has
User1 User2 User3
I need the output to be as below:
1 User1 Date 12/31/9999 2 User2 Date 12/31/9999 3 User3 Date 12/31/9999
I can use the nl utility to get the numbers easily enough, but I need two tab separations between the number and the user list. Is there a sed command that will insert at the beginning of each line? If so I can just run nl after I get some tabs up in the front.
Did anyone heard about or can suggest mabe a postfix serverside solution in order to insert a counter number into the subject line before the message is sent? I mean something similar with helpdesk tickets, because I would like to create the possibility for the senders, to make further refference about a speciffic message using it's counter number provided by postfix server.
I have two files, file1.traj and file2.traj. Both these files contain identical data and the data are arranged in same format in them. The first line of both files is a comment.
At line 7843 of both files there is a cartesian coordinate X, Y and Z ( three digits ). And at line 15685 there is another three digits. The number of lines in between two cartesian coordinates are 7841. And there are few hundreds of thousands of lines in a file.
What I need to do is copy the X Y Z coordinate (three digits) from file1.traj at line 7843 and paste into file2.traj at the same line number as in file1.traj. The next line will be 15685 from file1.traj and replace at line 15685 at file2.traj. And I dont want other lines (data) in file2.traj get altered. This sequence shall be going on until the end of the file. Means copy and substitude the selected lines from file1.traj into file2.traj.
I tried to use paste command but I cant do for specified line alone.
Here i showed the data format in the file. I used the line number for clarity purpose.
I want to access a file, and check the length of every line.After, i want to check and replace all lines with length over 10 characters, with a message.Does anyone have a clue on that?
I am trying to write a program in C which compares two files and prints the line that is equal.
Here file1.txt has
and file2.txt has
Note: file2.txt consist of only a single string where as file2.txt has multiple lines. Actually im comparing two files with md5sum values.
Here is the code but it compares only first line of files..but it should compare the whole file1..and sorry iam a beginner in C can any1 sujest some modification to this code so that..it can compare file2 with entire file1
Code: std :: map <QString, std :: vector <std :: pair <QString, QString> > > configFileDataVector; How should I insert data in it? All the examples which I have looked up in Google are of plain maps!
I've been reading tutorials of Linux sed command, but haven't got anything yet. the problem is : I want to insert a line into my DNS database file which has a pattern like below:
<Domain name> 3tabs here <IN> <A> <ip address>
the question is : how to add a line into a file like this using linux sed command? I have problem inserting tabs and the spaces!
I want to insert graphics into latex file, for longtime I used xfig to create graphs, but it is limited,specially for math formulas, dia i find not easy to use.Finally I want to try asymptote or tikz which one is more appropriate
My problem is to insert one sign like space or ':' into a line or string.The goal is to get a demiliter for `cut`.I tried to do it with `tr A-Z "'A '-'Z '" and such but without success.I guess a while read loop could do it but I don't know howto use it with ` expr length $STR`
I am looking for information to insert kernel module into kernel. I am not looking at dynamically insert of kernel module using insmod, modprobe etc. I am looking for statically insertion of kernel module procedure, such as what to change on makefile, what to change on menuconfig, what to change on .config file, etc.
i trying to add text messge in textarea and i got error in connection and i don't know if it correct syntax. and i wonder when i was install xamp server it no password required. but i dont know what password that i input in my php connection.?