Programming :: Using Sed To Remove Line In A Comma-delimited File?
Mar 10, 2009
I have a script that output all my data in to a comma-delimited file separated by ";"
Current Output:
Quote:
"SAP 1117A";10.94.1.7;239.234.1.12;0;0;0;0;0;3;172.31.207.45;""
"";NA;239.192.1.50;0;0;0;0;0;3;172.31.207.61;""
"";NA;239.192.1.50;0;0;0;0;0;3;172.31.207.62;""
[code]...
I would like to remove all lines that have an NA in the second field.
New Output
Quote:
"SAP 1117A";10.94.1.7;239.234.1.12;0;0;0;0;0;3;172.31.207.45;""
....
View 4 Replies
ADVERTISEMENT
Nov 23, 2010
I would like to create csv output from an ipcalc calculation.
Code:
[me@host scripts]$ ./ipcalc 192.168.30.40/255.255.255.248
Address: 192.168.30.40 11000000.10101000.00011110.00101 000
[code]....
View 1 Replies
View Related
Nov 26, 2010
I have been searching previous posts but could not find an example which works with my data. I think I might be the spaces in my fields. I have a massive data file and need to join 5 line blocks separated by a comma.
Code:
2
111.222.333.444
host.edu
[code].....
View 8 Replies
View Related
Apr 7, 2010
need to monitor pecific processes over a time frame in terms of the amount of memory and cpu usage it utilizes. I can do this using the top -p <pid> option and using ps to retrieve the pid's. However, seeing that the pid's might differ and it needs to be run on about 13 different machines, I would like to write a script for this that can be run at set intervals. My problem that I have is this:
- When running top -p <pid> I can specify a comma seperated list of the processes required to monitor at that specific time.
- I can use ps -ef | grep <process> | grep -v grep| awk '{ print $2 }' to retrive the list of pid's and output this to a file.
However, how can I output these to the file as a comma seperated list without having to manually do this every time? The reason for this is (an example), lets say I want to monitor the cpu and memory usage of postgresql as well as all its child processes, then I would ps grep for postgres and get the list of pid's for instance.This list then needs to be passed to top -p as a comma seperated list of pid's I suspect that awk or sed might have some options available for this but I do not know this well enough.
View 11 Replies
View Related
May 22, 2010
I am looking for an application that will read the file names in a folder and generate a comma delimited file. I want then to import the comma delimited file contests to a spread sheet such as open office.I hava a number of PDF files generated from a scanner, each file with its own scaner generated file name. I want to put these into a data base so I can add the title and other reference information to provide a data base.
View 7 Replies
View Related
Sep 26, 2010
I have a pipe delimited flat file, field 27 is price. I would like to move items marked sold to a new file every couple months.
awk -F"|" '$27 == "SOLD" {print $0}' awktest2.data >> awkout2.data
Allows me to write line to new file but I need to delete the original line, I also want to make sold case insensitive tried [Ss][Oo] with no luck
View 4 Replies
View Related
Nov 10, 2010
I have a CSV file that's created in an application that can't output lines longer than 250 characters. the data fields, all together, are longer than this. how would I remove the line break from every line that ends with a comma? For example:
A,B,C
D,E,
F
G,H,I
becomes:
A,B,C
D,E,F
G,H,I
View 1 Replies
View Related
Mar 4, 2010
Suppose i have a file(1.txt) separated by TAB delimiter in a line
1 B AB 2
2 C AB 2
if I need to search for the records having B?? using grep.If i need to perform multiple search like line having "C and AB" or "B and AB"??
View 5 Replies
View Related
Sep 4, 2010
I have a requirement like this:Cut the characters from each line of a file with following positions: 21-24, 25-34 ,111-120.Thse fields now need to be placed in a tab delimited output file.Currently this is how I am achieving it:
#!/bin/sh
cat newsmaple.txt | cut -c 21-24 > out1.txt
cat newsmaple.txt | cut -c 25-34 >out2.txt
[code]....
View 1 Replies
View Related
Jan 6, 2010
I am trying to do this:
1. Read csv delimited file line1 and store all values in array
2. Use the values stored in the array and replace values in other text file with them
3. read line2 in the cvs file and repeat the process
4. Do above for all lines in the cvs file
for example:
file1.cvs content:
text1,text2,text3,"text 4"
a1,a2,3,"a 4"
file.txt content:
some text $array1$ some text
some text $array2$ some text
1. read line 1 - text1,text2,text3,"text 4" put each value in array X[] lines that contain spaces in cvs will have double quotes
2. read x[1] and replace value $array1$ (in file.txt) with x[1]read x[2] and replace value $array2$ (in file.txt) with x[2] and so on
Can above be accomplished in BASH and how?
View 1 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
Oct 12, 2009
I have a fairly long list of data that I am trying to put into a math program (maple) but before I can do that I need to edit the format of the data such that at the end of every 25th line I add a comma. I would prefer a solution that uses vi, but if that's impossible sed would be fine also (or awk).
View 6 Replies
View Related
Feb 13, 2011
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?
View 1 Replies
View Related
Jun 3, 2010
I'm having a bit of a headbanger trying to work this one out. I'm trying to remove all of the characters on a line apart from the last 17. For example, I need to change this:
Code:
00000000000000000089;0bbfaeb8
01000000000000000089;0bcb5948
00000000000000000089;0bcc4c40
[code]....
View 5 Replies
View Related
Apr 11, 2010
I have a project due for my Intro to C++ class and we are suppose to generate a file listing that will take an input of a C++ source code with .cpp extension and make a copy of it with a .lst extention that will have a line number preceding each and every line.
View 12 Replies
View Related
May 25, 2011
I have a big csv-file wich is not formatted very well. I clean it up with removing a lot of html etc, but some of the lines breaks where they are not supposed to.What I want to do is to check next line, if it starts with 'PX' I don't want to do anything, but if it does not start with 'PX' I want to merge the two lines. That is removing the newline character on line one and replace it with a space.Can this be done with sed? (or maybe with perl or something, but I'm more familiar with sed)I've been looking und the net to find a solution, but to no result.
View 8 Replies
View Related
Jan 3, 2011
I wish to add information to one of my files based on matching IDs,
Here is an example
(the id is the 3 colunm)
(the ID is the 2 colunm)
And the output i wish to be
OUTPUT:
So as you can see the ones that do not match are still present, and the ones that do match just have the extra information from file2.txt added to them.
I thought about using join but that only seems to join the ones that match displays thoes only. i would like all the information in the output file.
View 6 Replies
View Related
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
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
Feb 9, 2010
i'm trying to get several strings from a single string, separated by comma's.there are comma's that do not separate strings, however, those enclosed in parantheses.an example would be:vt, word1, (word2, word3)word4
exploding by ',' would result in:
[0]=>vt
[1]=>word1
[code]....
View 2 Replies
View Related
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
Mar 2, 2010
In C, I want to make a program that will take a file and replace it with a file that's nearly the same but with some minor changes. Also, I would like to point out that I'm still fairly much a beginner with C. As for an example of the file, I want to take something like this:
Code:
Random Crap
More Random Crap
Even More
Something That Changes XXXXX
[code]....
I figured the best way to go about doing this was to open the file and a blank file, read the original bit by bit and when it gets to the point that needs to be changed exchange the part that needs to be changed with what it should be changed to, delete the original file, and rename the new one to the correct name. So the first problem I've run into (and I'll probably have more) is that when I'm trying to read stuff from the original file, my program doesn't seem to be finding the original. I'm sure much of my problems will be just from not knowing how to use the C functions so bear with me. Right now I have the following:
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
[code]...
And when I try to run it I get the following:
Code:
Died Here: No such file or directory
Segmentation fault
Right now the length of 50 was just a random test length. Pretty much I was just trying to get it to read anything from the file. In the end I'm going to want it to read the entire file bit by bit, but at the moment I can't seem to get it to read anything.
View 11 Replies
View Related
Mar 6, 2010
I have a code over there. It reads a line from file and converts contents of it to double.
Code:
/*
* fileRead.c
[code]...
View 2 Replies
View Related
Mar 25, 2010
I need a qtimer to trigger reading of a file line by line, I have the code sort of running with the timer trigger but qtimer will just read the first line over and over as it is now.
Here is the code so far:
self.lcdtimer = QTimer()
self.connect(self.pushButton85,SIGNAL("clicked()"),self.update)
self.connect(self.lcdtimer, SIGNAL("timeout()"), self.lcdxyz)
Code:
def lcdxyz(self):
import time
import os
[code]....
View 12 Replies
View Related
Mar 21, 2010
I'm trying to compose a line of numbers each single digit taken from a variable eg: 1010001 each variable digit is either a 0 or 1 made from variable layer1 through 7. I need to add each layer variable to the last to compose the number with no commas or spaces and add it directly after the -p option in the show_command line. I used array and list and the commas mess up the command and inserting "pens" in the show command interpertes it literally instead of the list or array value? The insert should look something like 1000110
Code:
View 1 Replies
View Related
Mar 6, 2010
in a tab-delimited file, such as:
Code:
111aIab
222bIIbc
[code]...
View 3 Replies
View Related
Jul 25, 2011
I'm using sed to remove certain line in a text file based on a match with 2 variables from input. Here is how it looks like in file
Philip S:Odds:45:343
Mike Junior:Odds:3:56
I prompt for 2 inputs in variable form which is compared to the first 2 fields of the above text (: seperated). So say i enter Philip S and Odds then it should delete the entire first line.
View 4 Replies
View Related
Sep 23, 2010
I did some searches and after a few hours was able to get what I needed. What I didn't find was a fully encompased means of what I'm used to in the windows world in working with delimted files. Hopefully this is helpful to others and if there is something better or leaner way, even better.We have an issue where managing printers, just viewing on RHEL w/ sys-conf-prtr we lose any number of, up to ~30 printers from lpadmin. Rather than stare and compare to find the missing ones, I wanted to make an intuitive script. This is what I came up with.
Code:
#!/bin/sh
while IFS="," read Prntr IP; do
[code]...
View 3 Replies
View Related
Jul 20, 2011
I am writing a bash script to run everyday and output results to a file. When the same results are produced i want to overwrite the line from the previous day. (Or remove and add). So if the script finds a variable in a line. i want it to output the results to that line . sed -i did not work for me; sed: couldn't open temporary file ./sedTvOCEg: Permission denied
View 10 Replies
View Related
May 29, 2010
I've never programed shell scripting.
Code goes like so:
I simply want to read a file "data.txt" line by line Then char by char and add them into a result var. The file is supossed to always contain numeric values
View 8 Replies
View Related