Programming :: Inserting Some Text Into A File Using 'awk' Command?
Oct 20, 2010
I'm gonna replace my machine's ip address and hostname using awk command. the pattern of the file is like the following...ip address="192.168.1.100"the script must ask the ip address from the user and replace it with the ip address in the quotation.
View 14 Replies
ADVERTISEMENT
Aug 26, 2010
I'm writing a C program, and using Autotools. I have a large text file that I need to include verbatim, as data for my program.I used to have a hacked-together Perl script that would take a file like this: Code: A Rabbi, a Priest, and a Minister walked into a bar.The bartender said, "What is this, a joke?" I found this site that contains instructions for doing exactly what I want, but that technique requires GNU's ld, and the whole point of using Autotools in the first place is to make my project platform- and compiler-independent.I should point out that, according to the Autotools help, I can do this with a script called either "txtc.sh" or "txtc.sh.in". Unfortunately, Google can't find such a script, and it's not in any package that I can find.
View 12 Replies
View Related
Apr 18, 2011
Just using shell scripting, how can I insert text into the middle of a file name. The file has a predictable pattern, let's say 3 letters and 3 numbers and I want to insert text in the middle of those 2 patterns. Say ABC123 is the file name. As a result, the file name should be ABC.blah.123
View 2 Replies
View Related
Feb 12, 2010
I want the below line of text to be inserted in a file.Description "Linux Group" $1i am using sed "10 iDESCRIPTION "Linux Group" $1" filenamebut because of the "Linux Group" my code goes into infinite loop.Please let me know how i need to print Linux group with the double quotes in my file.
View 4 Replies
View Related
Jan 28, 2009
I have a text file called file1.txt containing many lines eg.
line1
line2
line3
line4
line5
line6
Then i have another text file called file2.txt contains
3
5
6
Is there a command to remove the lines in file1.txt based on the keywords in file2.txt? note: It should remove line3,line5,line6 based on 3,5,6
View 10 Replies
View Related
Jan 19, 2009
I need to insert 3-4 lines of text to the beginning of a text file. The file is a largish MYSQL dump, the result of a backup shell script. This shell script should insert the required text.I've wrestled with sed, but lost.
View 2 Replies
View Related
Jan 13, 2010
I have to delete a certain line of text from the a textfile via ubuntu's shell scripting.I have done research, and it seems that most people advocate the usage of sed /d option. sed makes does not edit the text file. Hence, most options I discovered involved the use of a temporary variable/textfile and then overwriting the old file with the temporary new file. Is there anyway whereby I can bypass the use of temporary storage containers? I hope there is any magical combination of commands to edit the file directly.
View 3 Replies
View Related
Jan 8, 2011
I want to display something in my text view widget in glade using c code. that's all right.
now I need to attach a save button beneath the text view.so that on click the text view content should save as a txt file..
View 8 Replies
View Related
Feb 9, 2011
I want to display the contents of a particular log file (simple text file, I mean in Linux). But there is a problem: The contents need to be organized in a fixed format. Have a look at this log file:
sampleLog.txt
Code:
User Name: XYZ
Reported Problems Description: Blah! Blah! Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah!
[code]....
So, while displaying the contents of above file on a web page, I want to format the field names found in the log file: User Name:, Reported Problems Description:, and Remarks:. These fields may contain a variable length of text and no specific line number is assumed for them to appear on.
The desired output should look like this:
User Name: XYZ
Reported Problems Description: Blah! Blah! Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah! Blah!Blah!
[code]....
Well, what I am trying to do may sound wierd to some of you. The filed "Reported Problems Description:" can possible contain text which embeds colon (.
View 15 Replies
View Related
May 3, 2010
a sed command to add a text before line number in text file? I have text file with 500 lines, and i want to add 3 more lines with text after line 300, OR before line 302, isn't no problem.
View 16 Replies
View Related
Aug 23, 2011
I need to be able to convert HTML email messages saved as text files (.eml or .msg) to PDF documents, one PDF per email, retaining formatting and images.
Are there any Linux tools that will allow me to do this from the command line (so it can be scripted)?
View 1 Replies
View Related
Oct 14, 2010
I want to be able to check the contents of a text file for a specific string and remove it from the file from the command prompt. I would basically be searching through a number of files and if a specific string is found I would like it removed automatically. pretty much a find and replace, were the replace is nothing. any one got any ideas on how you would do this. I already have the search part sorted just need to be able to remove the string I don't want from the multiple files.
View 4 Replies
View Related
Apr 19, 2011
I have a .txt-file with ~50.000 lines of numbers, generated by a mathematics program. From this file, I need line ~ 1.100 to line ~16.000 (these lines are always the same btw, this may make the solution easier, dunno) to be copy/pasted to another file, where the lines ~500 to ~15.000 (also, every time the same) should be overwritten by the aforementioned lines...I haven't found or come up with anything that works yet, mostly I find solutions to copy everything from one file to another but I can't find something to specifically overwrite a part of a file with part of another.
View 4 Replies
View Related
Oct 11, 2010
I have a String like "A.words=Ajay,Anil" in file A.And it contains a lot of other information also. I wanted to replace "Ajay,Anil" with "Vijay,Vinay" with sed command with using existing file only(not using another file)
View 9 Replies
View Related
Nov 11, 2010
What I plan to do is, create a duplicate file of a text file, and then append some text into the new text file.
View 1 Replies
View Related
Oct 4, 2010
I want to insert the text "DB dept" in the last line of passwd file which looks like this right now
Quote:
newuser:x:717:717::/home/sacharje:/bin/bash
And I want it to be like this:
Quote:
newuser:x:717:717: DB dept:/home/sacharje:/bin/bash
I tried to do that with sed but failed, I'd like to know the proper syntex with sed to achieve this.
View 7 Replies
View Related
Feb 11, 2011
I have an SQL dump, file.sql that has many references to a particular domain, d1.com. I would like to run a command that can replace every occurrence of d1.com with d2.com. I've tried looking into sed before but the man pages are quite daunting.
View 14 Replies
View Related
Jan 28, 2010
I need to be able to edit a file from the commend line as I intend to script this operation, the file is called menu.lst The original is as below
Code:
titleUbuntu 8.04.3 LTS, kernel 2.6.24-24-generic
root(hd0,0)
kernel/boot/vmlinuz-2.6.24-24-generic root=UUID=b09feb23-5524-4ec4-862f-94700b968f64 ro quiet splash
[code]....
View 4 Replies
View Related
May 14, 2010
What is the command to sort a text file by the second word?
View 4 Replies
View Related
Feb 17, 2011
how can I set the cat command to read specified lines of a text file,like if I have a text file with 100 lines, who can I say cat only line 23 to 42?
View 3 Replies
View Related
Dec 2, 2010
First I hope to undrestand my English word because Iam Arabic girl and not so good in English...
my problem is:
I wrote code in .c file and I run that code on the prompt command, its ture but I want after the out put copy the code on the command by some statment in the code , how can I do that?
View 3 Replies
View Related
Apr 3, 2010
I'm having problems with Tomboy. I have a few hundred note files and I need to go through all of them and replace all instances of "<link:broken>a</link:broken>" with "a". Is there a bash command I can use to do this?
View 2 Replies
View Related
Jul 28, 2010
How to output to a text file the compound command:
Code:
find -type f -print0 | xargs -0 grep -l "desired text"
I have not been able to find the answer.
[code]...
View 5 Replies
View Related
Oct 18, 2010
I've created a script to test network speeds but I've run in to a little problem. The command outputs this:
Code:
Client connecting to 192.168.111.230, UDP port 5001
Sending 1470 byte datagrams
[code]...
View 1 Replies
View Related
Mar 11, 2011
I have been working on this since 3 days but wasn't able to achieve what I want
I have a big text that has the following format:
Current max fieldLen for table1 (a):
Fld# Width MaxWidth ERR NAME
---- ------ -------------- ------ ---------
2: 80 38 *** field-name
3: 4 2 field-version
4: 40 7 field-value
[Code]....
View 7 Replies
View Related
Apr 28, 2011
I have a text field that is just list of servers and I need to add the word hostname in front of them... It must be brain fart but I can't think of how to do this. Basically I need this:
server1
server2
server3
To this:
hostname server1
hostname server2
hostname server3
(And I just mean simply the word "hostname")
View 2 Replies
View Related
Feb 10, 2011
I need a sed and renaming the text in file. we have this one:
Quote:
Originally Posted by nickname
nickname presents: $subject
Size: size
[code]....
View 2 Replies
View Related
Mar 31, 2010
I am not especially cli adept so could someone tell me the best way to use the diff command to get the difference between a string of text and the contents of a file instead of between the contents of two files?
View 3 Replies
View Related
Jul 29, 2011
I don't understand why this is so difficult.In the old days, there was lpforms which allowed some formatting. CUPS did not see fit to implement this into it's lp package.cgi-...-cgi?lpforms+1In the old days, lpr allowed you to select a font in the command line with -1=fontname. CUPS did not see fit to implement this into it's lpr package.htmIn the old days, printers had fonts installed on them that you could access. Modern printers don't seem to have this. So now I still need to be able to select a font when I print certain text files from the command line but it seems this is impossible. I've been working with instances and lpoptions, which allows me to do a lot of other things I need like orientation and margins and even set the font size, but I still cannot choose a font other than the default.
View 2 Replies
View Related
Mar 10, 2011
I wish to append a text at the start of every line and save it to another file without changing the original file.know the command
For example:
Orignal.txt
a.txt
[code]...
View 5 Replies
View Related