General :: Remove Specified Line From Text?

Feb 12, 2011

I wish to move a specified line from a text file:

Quote:

ltoremove=5 #remove 5th line
i=1
while read line ; do

[Code]....

how should this actually be done? is there a shorter faster way to do this?

View 7 Replies


ADVERTISEMENT

Ubuntu :: Remove Specified Line From Text?

Feb 12, 2011

I wish to move a specified line from a text file:

Quote:

ltoremove=5 #remove 5th line
i=1
while read line ; do

[code]....

how should this actually be done? is there a shorter faster way to do this?

View 3 Replies View Related

Red Hat / Fedora :: Remove Particular Line Of Text From All Php Files

Jul 21, 2010

My site was recently hacked and a line of <JAVASCRIPT> was inserted into all my php files. Is there a way to pull just that one line out of all the php files on the server? I was thinking of using a grep -iR <CODE> *.php then piping thru sed

View 1 Replies View Related

General :: Match And Combine 2 Text Files Line By Line

Mar 21, 2011

This solution works but is slow with large files. I am looking for a faster solution.

The 2 files contain filenames, one of them has associated data I want to append to the other file's matching filenames

file1:

file2:

I append file2 by matching the unique_filenames and appending them with the tag data and some formatting

appended file2:


Here is the SLOW code

while read inputline.

View 9 Replies View Related

General :: Getting Numbers From A Line Of Text?

May 10, 2010

I'm working with a rather large file of data taking from a tracking program on my phone, and trying to pull only the longitude and latitude from it. Any given line in the data looks more or less like this:

{"lon":-122.3083848,"time":1.273515839496E9,"source":"skyhook","nap":28,"altitude":0,"name":"location","hpe" :29,"bearing":0,"ncell":0,"lat":47.6544453}

I've run it through this command:

grep skyhook log-2010-05-10_18-17-28.json | cut -d"," -f1,10

to get this:

{"lon":-122.30872015,"lat":47.65812201}
{"lon":-122.3076686,"lat":47.6569975}
{"lon":-122.3079161,"lat":47.656395}
{"lon":-122.3096168,"lat":47.656218}
{"lon":-122.3096285,"lat":47.656206}

Which is a lot nicer, but I would prefer not to have to hand remove the non-number characters by hand since there are thousands of data points. what I could do to get it to just be longitude and latitude in 'number number' format?

View 8 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

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 :: Echo Text With New Line In Bash?

Jun 21, 2010

I would like to append text to a file. so i wrote in bashecho text >> file.confHowever it doesnt leave a new line. So i can only do this once. How do i add a new line?

View 2 Replies View Related

General :: Adding Text To End Of Particular Line In Bash

Nov 30, 2010

I am looking at how to add particular text to a file in bash.Here is what I am trying to do:In the /etc/grub.conf file, I am trying to add "audit=1" (without the quotes) to the end of the kernel line...such as:kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/1 rhgb quiet audit=1

As there are a few different lines in this file, I am only looking to add the "audit=1" to the above line via a bash script.

View 7 Replies View Related

General :: Bash - Add Text At The Beginning Of A Line

Feb 28, 2011

I have a lot a folders, each named by a number, and in each of these folders I have a specific file (stddev.dat) containing a single line (of numbers) I need to have a single file with each line being one of the stddev.dat (no matter if it is sorted or not), and also I need to add at the begining of each line the number of the folder it comes from.

I 'm no bash expert, and the "add at the begining of the line" is a bit of problem to me". Here is what I've come up with so far, just to put everything in one file, (and also if you know a better/more elegant way to do the same thing I've done, I'm listening)

[Code]...

View 6 Replies View Related

Software :: Grep Query To List 1 Line (which Is Fixed) And The Next Line After It (variable Text)

Jan 20, 2011

How can I list the following with grep. I want to extract 2 lines fron a text file The fixed known part if it exists will static text and the text line after it will change.

A sample file
.
.
textline1

[code]....

If the fixed part does Not exist how can I return error code 1

View 3 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: Each Line Of Multiple Text Files Gets Added To One Line?

Sep 12, 2010

I currently have 3 files with floating point data that I wish to have in a single file with the format:

Code:

F1 F1 F3 Output
a1 b1 c1 a1 b1 c1
a2 b2 c2 a2 b2 c2
a3 b3 c3 a3 b3 c3
a4 b4 c4 a4 b4 c4

View 3 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

General :: Remove Words / Text In Directory?

Feb 24, 2011

I have a folder with many many files. e.g html, docs, excel sheet, script etc.
Now I want to find {using grep command}a certain word in that folder/directory and delete it in all the files and scripts that have it.

For example, I want to delete the word /testing (with the slash) in all files in a directory.

View 14 Replies View Related

Ubuntu :: Add / Remove Bits Of Text From A Text File

Dec 6, 2010

I am looking for a way to keep a log and make if then statements if a line exitsts in the log. I also am looking for a way to make a simple loop, like goto line number, and I also am wondering how to add/remove bits of text from a text file (plugins line in server.properties)

View 5 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 :: Using Python To Merge Two Text Files Line For Line

Jul 6, 2010

I'm a bit new to Python programming and hoped that someone might be able to help with a problem I'm having. What I essentially want to do is to combine two text files line for line. I know how to do this in a bash script so to give you a better idea here's the code for that:

Code:

This is basically for adding on values to the end of a CSV file that uses ';' as the delimiter. So say file1 said:

And file2 said:

Then running this command would create merged_file1_and_file2 which would be:

The code I'm using at the moment is:

Code:

As I'm sure any experienced python programmer will see, this prints out the first line of the file "csvraw" and then all of the lines of "stamps" and then the remainder of "csvraw".

What I'd like to do is something like: (pseudo code, I know it's not python ;-))

Code:

Is this possible? I've tried googling and my Python Pocket Reference hasn't been much help. I've looked at pickling but that doesn't seem appropriate.

View 1 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 :: Replacement On More Than One Line In Text Files Using Shell

Nov 25, 2010

How can I replace one instance of a word in a text file with a piece of text that spreads several lines ? I know sed or awk is the way to go but don't know that how I can introduce new paragraphs using these tools

View 1 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 :: 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 :: 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

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 View Related

General :: Remove All The <a Href Links From Text File?

Mar 24, 2010

[Code]....

I am trying to remove <a href links using SED but unable to do it.

The finale result I am looking for is

[Code]....

Is it possible with Linux or should I try with Php?

View 2 Replies View Related

General :: Remove Duplicate Words Within A Particular Text In A File?

Jul 22, 2011

I am basically trying to remove duplicate words in my <title></title> tag after I got hit by Google Panda. I have around 750 .html files and it will be difficult for to me remove one by one. I am looking for a way to remove only from within <title> </title>

Example of a duplicate title I have:

Code:

<title>Pasta, Pasta Recipe and Pasta Guide</title>

I dont want to replace those words anywhere else in the file except for within the <title>

View 14 Replies View Related

General :: Remove Lone Lines From A Text File?

Jul 6, 2011

anyone has ideas how to remove lone lines from a text file?

If I have a file that is like this:
-----------------------------------
line 1

[code]...

View 14 Replies View Related

General :: Remove Line From Crontab?

Aug 26, 2010

I have exactly same line like in crontab and I want to remove it via shell script. How to do it?

Example:
In crontab there are:
*/1 * * * * /home/testdir/testcron.sh >/dev/null 2>&1
line, how to remove it using shell ?

View 14 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







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