Programming :: Add A Column To A Text File?
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
ADVERTISEMENT
Jun 13, 2011
I am trying to import a data file from old DOS application into MYSQL table The file is clear text file with fixed-width columns, without column delimiters
Example file :
Code:
4444333666666
2222666555555
iiiiwwwcccccc
[Code]...
View 3 Replies
View Related
Jul 17, 2011
I have 2 large text files , one looks like this:
<contact type="1">blahblah@hotmail.com</contact>
<contact type="1">blahblah2@hotmail.com</contact>
<contact type="1">blahblah3@hotmail.com</contact>
The other is a list of emails in single column format like this:
emailaddy@hotmail.com
emailaddy2@hotmail.com
emailaddy3@hotmail.com , etc
Is there a command to delete all the blahblah emails from text file 1 and replace them with the ones from text file 2?
Or maybe a linux version of 'Csved' which has the ability to add,remove,insert columns?
View 5 Replies
View Related
Sep 4, 2010
Code:
#!/bin/bash
ls -lhGg | while read line; do echo "$line"; done | awk ' { print $3" "$6 } '
what i want to do is be able to print column 3 and every column greater then 5. Has to be to the end of the line, since different filenames can have different amounts of words in them and the blank space is the separator. my current code works just fine if the file has no blank space.
View 8 Replies
View Related
Jul 15, 2010
I have a multicolumn datas, like
a1 b1 ... f1
a2 b2 ... f2
. . ... .
[code]...
I would like to make a file with all these data in one column, like
a1
a2
.
.
[code]....
Can it be done with awk or some other command? Also, is it possible then do add another column in front of this one with numbers of the lines (for every previous column), like
1 a1
2 a2
. .
. .
[code].....
View 14 Replies
View Related
Jul 2, 2010
i have a script to read a file and get each column with varibles.actually my file: hplog1 sample 3 lines consists of
client1_day- 2010
jan
client2 2009
[code]....
View 1 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 7, 2011
All I want is a command that reads one data file with several columns and prints it in another one.However, whenever the value in one specific column alters, it prints one empty line in the new file. For example, consider the file
2.54000000 2.54000000
2.54000000 2.54000000
2.54000000 2.54000000
2.54000000 2.56000000
[code]....
View 9 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
Sep 23, 2010
text editor that has column mode capabilities like UltraEdit?
View 5 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
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
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
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
Jun 30, 2010
I need to extract som text from a text file. The text is a test log with system info at the top and results further down. What I need is to add different tags with formatting before and after each line. I have prepared a template with html formatting, but the number of lines in the test log may be different from case to case, so I need to be able to add formatting tags by need. Can this be done using bash script, sed, awk, head, tail... ?
View 4 Replies
View Related
Dec 21, 2010
I have a file with 5000 lines. it is a list of books authors, series and titles. all lines start with the author names, than there is a dash (-) than the series name, a dash again and the title of the book.
The problem I encounter is that sometime there is a series, sometime not, and as I try to enter this list in a database, I wanted to create a cvs file to import into mysql.
ex:
The best would be to be able to add in the second line, a "space dash space" just after the author name, but how to make sure it does not do it to the first line as well.
If I could separate all line with 2 dash, (grep ?) then I would be able to do a simple replace, and change the single dash into two.
View 2 Replies
View Related
Jun 3, 2011
Code:
int main ()
{
[code]...
View 9 Replies
View Related
Aug 21, 2010
I have a plain text file with 360 lines of varying length text. How do I add a comma or other symbol to the end of each line so that I can convert the file to csv format that I can open in a spreadsheet (45 rows, 8 columns). That means each 8 lines of text forms 8 columns, with 45 rows.
View 9 Replies
View Related
Jun 23, 2011
Im trying to read a file in c++ and search for particular character for example if this is a list that I have:
Alice
Bob
David
[code]....
if the input is D, it should give David, if its B, gives bob. so in this case, meaning it reads the first character of every line. but if possible I want to make this dynamic so the user can specify which character position he is looking for, so in case he is looking for R as character index 3 in all lines, it should give Charlie. but the problem is, it does now recognize , besides, I do not know how to specify the character position in each line.
here is my code
Code:
#include <iostream>
#include <fstream>
#include <cstring>
[code]....
View 1 Replies
View Related
Oct 11, 2010
I need a script which can format the below text file which contains comments
Code:
Code:
Output should be:
Code:
Code:
Script should compare the column name and paste the output in above said manner.
View 13 Replies
View Related
Aug 25, 2010
I need a way to read and delete text found before a unique string, then delete the string. I would like to have the text stored in a variable--or better yet--executed it as a shell script directly.I intend to execute the stored text in bash. It does not matter much what language the program is it, however efficiency is desirable. This script is not going to be used on large files, but it may be executed many times sequentially so the faster the script works the better. Here is an example:
exclamation-"It worked!"
echo $exclamation
cd
[code]....
View 7 Replies
View Related
Nov 22, 2010
I have a log file and want to extract all blocks of text that start with START and ends with END. Each block is 5 lines.
Code:
--- START
blah blah blah
[code]...
View 1 Replies
View Related
Oct 19, 2010
a project using bluetooth to send data byte by byte to external devices buti'm not familiar using arrays to read file from another location before sending the data.If you could,do correct my codes.Here's my code,
void loop(){
char Msg[]={"Hello"};
char *start;
[code]...
View 2 Replies
View Related
Nov 6, 2010
Say I have a text file like:
Code:
1
3
4
How would I use ksh to put the number '2' into the second line of that file?Okay it's not bash, it's ksh because this computer is OpenBSD
View 14 Replies
View Related
Jan 16, 2011
how to work properly on the windows forms application in c++.
the thing is that i was able to produce in the windows forms application a web browser and I added a save button. So know I am able to navigate predeclared webpages such as [URL]and then I entered google's search box such as "spread of H1N1". and I surf a page such as [URL] I later save the page as text file on my computer.
I wanted to know how to organize the words in the text file ? i mean how can i just get the number of infected people in USA , number of infected in CANADA (if they exist) from all the text file and change it to a file with precise data.that is to eliminate the unneeded information such as the the characteristics and the useless ideas? and what if i also wanted to know the characteristics of the virus in a country+the number of infected?. How can i do it?
View 3 Replies
View Related
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
View Related