General :: Insert Text To A File Using Command Line?

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


ADVERTISEMENT

General :: Insert Text In The Last Line Of A File With Sed Command?

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

General :: Insert A Line Into A Text File Using "sed" Command?

Sep 18, 2010

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!

View 7 Replies View Related

General :: Insert Line Into A File With A Command?

Jan 4, 2010

I would like to insert a line into the /etc/sysconfig/iptables with a command like sed or with any script. How can I insert this line:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

but under the line "-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT"

View 2 Replies View Related

General :: Insert Text To A Specified Line?

Aug 23, 2009

Code:

sed -n '123p' file

that will print line 123 but how might I insert text to a specified line?

View 3 Replies View Related

General :: Convert An HTML Email Saved As A Text File To A PDF File From The Command Line?

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

General :: Selecting A Font When Printing A Text File From The Command Line?

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

General :: Command For Appending A Text At The Start Of Every Line And Save It Another File?

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

General :: Insert Tab At Beginning Of Each Line In File?

Aug 5, 2010

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

Where the columns are separated as below.

1[tab][tab]User1[tab]date +%D[tab]12/31/9999
2[tab][tab]User2[tab]date +%D[tab]12/31/9999
3[tab][tab]User3[tab]date +%D[tab]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.

View 2 Replies View Related

Programming :: Insert Line Of Text Prior To Pattern Only Once?

Jun 29, 2010

I have a file like so:

Code:

one
two
three
four

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.

View 5 Replies View Related

Programming :: Insert A Line/value After A Particular Line In File With Sed?

Jan 13, 2010

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

View 3 Replies View Related

General :: SQL Like Group By And Sum For Text Files In Command Line?

May 2, 2010

I have huge text files with two fields, the first is a string the second is an integer. The files are sorted by the first field. What I'd like to get in the output is one line per unique string and the sum of the numbers for the identical strings. Some strings appear only once while other appear multiple times. Given the sample data below, for the string glehnia I'd like to get 10+22=32 in the result. how to do this either with gnuwin32 command line tools or in linux shell?

[Code]...

View 2 Replies View Related

General :: Text To ASCII Art Command Line Tool?

Oct 24, 2010

I want a command line tool that echoes a string in ASCII art way, like here.

View 2 Replies View Related

General :: Uploading A Text Into A Webpage From Command Line

Apr 1, 2011

my webpage PHP below. I would like to enter "Hello, in the main inputbox field" below (You are editing: textfile.txt) and click "SAVE" directly from command line.

Sort of : wput_php "hello, in the main inputbox field" click save, and here is it. the text would be uploaded.

PHP Code:

[Code]....

View 2 Replies View Related

Ubuntu :: Sort The Output To A Text File So That It Prints To The Text File At 1 Process Per Line?

Feb 6, 2011

im trying to output a list of running processes via a shell script. At the moment i got this which outputs the processes to a text file called out.

echo $(ps aux) >>out

The problem is though, the processes are all just one big block of text which makes it hard to read. Does anyone know how to sort the output to a text file so that it prints to the text file at 1 process per line? I know its probably simple but im very new to linux.

View 5 Replies View Related

General :: Command Line - Print A Group Of Text Matching A Regex?

Sep 22, 2011

I'd like to print only few groups from text matching a regex. How can I do that in the Linux command line?

What other tools for text processing are there in Linux?

View 3 Replies View Related

Programming :: Insert Each Line Of One File To The Another File After Certain Lines?

Jul 2, 2010

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

View 14 Replies View Related

General :: Command Line Way To View A Line Of A File With Context?

Feb 24, 2011

I'd like show a certain line or lines of a file with context, kind of like a unified diff, on the command line in Linux:

$ (something) -l 154 stuff.py
150: def foo(bar):
151: """

[code]....

View 5 Replies View Related

Programming :: Insert A Line In The Test File With Sed?

Jul 15, 2010

I have following file workers file: There are 800 entries like this.

# consensus/uat
worker.consensus-uat1.host=lonlx10409
worker.consensus-uat1.port=13702
worker.consensus-uat1.type=ajp13

[code]....

I want to insert one line just below the line starting with "woker.list". I think sed can do it but I am not aware.

View 14 Replies View Related

General :: Cross-platform / Command Line Utilities To Convert PDF / DOC And DOCX To Text

Jul 28, 2011

I am making a text search engine. I need to first convert binary documents to text. I want to go with cross-platform (we develop both on windows and linux) command line (so that I can get the output via python subprocess). What are the choices for this?

View 1 Replies View Related

Programming :: Sed One-liner: Search Text In File And Replace It - If Not Present Insert It?

Oct 16, 2010

As indicated in the subject, I want to search a text. If the text is present I want to replace it. But if the text is not present, I want to insert it after first line and before last line.

Searched text is:CleanCache "*";

Where * can be anything.

Example: CleanCache "false"; -> CleanCache "true";

If CleanCache "false"; is not present, only insert CleanCache "true"; after first line and before last line.

View 8 Replies View Related

Programming :: Delete Line Of Text From Text File Via Shell?

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

General :: Replace Nth Occurence Of String In Each Line Of A Text File?

May 20, 2010

I have large text files with space delimited strings (2-5). The strings can contain "'" or "-". I'd like to replace say the second space with a pipe. What's the best way to go?
Using sed I was thinking of this:

sed -r 's/(^[a-z'-]+ [a-z'-]+) /1|/' filename.txt

View 2 Replies View Related

General :: Splitting Text File Into Several Parts By Line Count

Sep 21, 2009

I have a utility that works with files. The utility is crashing at after about 120 files. The input to the utility is a file containing a filelist. I want to cut the file with the file names in it to seperate files containing about one hundred or so. My thought was to determine the number of lines/100 and then use head and delete to create temporary files to run the utility multiple times to prevent the crash. When I tried to create a variable using the wc -l command the output gives me the number of total lines but it also includes the filename of the input file. (873 Filename.txt) I can not figure out how to remove the Filename.txt from the variable.

View 2 Replies View Related

Programming :: Open Two Text Files - Read Them Line By Line And Update Parameters Of The 3rd File ?

Oct 18, 2010

I have two txt files containing x and y coordinates: xcoord.txt & ycoord.txt. I need to open them; read them line by line to get each coordinate; then each time I need to update Xs and Ys parameters inside another file called "dc.in" with the grabbed values.

Finally each time I need to run two exe files ( dc_2002 and st_vac) and produce corresponding output for each Xs and Ys ( dc.in is an input file for this exe files)

I have written the following code but it does not work:

View 14 Replies View Related

Programming :: Perl - Delete Line From Text File With Duplicate Match At Beginning Of Line

Apr 1, 2009

Was wondering if any perl guru's could help me with a quick log file adjustment. I have a text file that looks like so (tabs and newlines are revealed so you can see what separates the data):

There are maybe 100 lines of text in this file at any given time. I need to delete all duplicate lines only looking at the first bit of text prior to the first tab. It doesn't matter which one gets deleted as long as there are no two lines that begin with that same text at the beginning before the first tab. So in this example, either the fist line "1234" or the last line "1234" would need to be deleted. I already have code in my script that opens the files - I just need the code to read the text into an array and the part that would find matches based on the above criteria, and make the deletions.

If it would be easier, I can even do a system call and use SED (v4.1.5) and/or AWK (3.1.5) instead.

View 7 Replies View Related

Programming :: Add Text Before Line Number In Text File?

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

Programming :: Bash: Read A Text File Line By Line?

Jul 7, 2011

bash 3.1.17(2) I'm trying do write a shell script which must operate on each line of an ASCII text file. So, all the code must be inside a loop, and inside the loop, the first thing should be to read the next line from the file. I have the bash read command. But it reads from stdin. Any way to make read from a file?

View 6 Replies View Related

Programming :: Insert Line Using Sed Or Awk At Line Using Line Number As Variable

Jul 25, 2011

I want to insert a line at a particular line number using sed or awk. where line number is not fixed and is in form of variable.

I want to use variable in sed or awk command.I tried something like below, but no luck.

View 7 Replies View Related

General :: Replacing The Text In Same File Using SED Command?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved