Programming :: Move Line Of Pipe Delimited Flat File If Field 27 = Sold?

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


ADVERTISEMENT

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

Programming :: In A Bash Script - Move A Line To A New File?

Apr 23, 2011

I've got a bash script I'm using to download a text file list of links via axel. What I'd like to do is automate the movement of completed links in the for loop when axel has successfully completed the download. This is what I've got. I can figure that I can just echo append the line to a new file, but what is the easiest way to delete the line with the link I just downloaded?

Code:

#!/bin/bash
for i in $( cat $1); do
axel --alternate --num-connections=6 $i
export RC=$?

[code]....

View 14 Replies View Related

Programming :: Searching Pattern In Tab Delimited File Using Grep

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

Programming :: Extract Specific Lines From A Flat File?

Mar 10, 2011

I'm trying to extract specific lines from a flat file. I need lines that fall within a range of coordinates. The -F can be either ! or = If the line is in this set range I need all of the data on that line. ranges lat 36 to 39 and longitude -74 to -84

awk -F '=' '{lat=substr($2,1,2); lon=substr($2,10,3); (lat >36 && lat <39) && (lon >-74 && lon <-84); print lat"--"lon}' < net.log

example line from the flat file
K4MQF-3>APN383,VA2-2,qAR,N3HF-5:!3818.65NS07800.17W#PHG77306/W3,VA3/Clarke Mnt

View 9 Replies View Related

Programming :: Pasting Multiple Cut Outputs To A Tab Delimited Output File?

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

Programming :: Bash - Reading Csv Delimited File To Array And For Further Manipulation?

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

Programming :: Extract A Part Of Flat File In Shell Script?

Feb 12, 2010

My rquirement is I have a flat file with lot of lines on it.example:

line1
line2
line3

[code]....

View 8 Replies View Related

Programming :: Awk - Print A Field When Field Position Is Unknown ?

Mar 28, 2010

I'm trying to display fields from flat files where the first 8 fields are always the same. Fields 9 - n are varied but will contain specific patterns I'm after. I'm using this so far because "mySearch" is on each line I want to examine.

Code:

How would you pattern match and include 2 additional fields above field $9 but change field position from line to line?

View 12 Replies View Related

Programming :: Handle A Broken Pipe Exception (SIGPIPE) In FIFO Pipe?

Mar 2, 2011

I've written a simple server in linux used fork to create a FIFO pipe.The server create two FIFO pipe.One for server read data from client and write data to client.Then another pipe for client read data from server and write data to server.When the server read data from a client used server-pipe and then write data to client.But ,if the client no read open the pipe,the server side write will be crashed because of a broken-pipe SIGPIPE. How to check whether the read side is opened?Or,how to catch the SIGPIPE,and then my server will still execute on,not crashed!!

View 5 Replies View Related

Programming :: Pipe Output Of Ls To File?

May 3, 2011

I want to pipe the output of ls in a folder to a file (lets call it test.txt) but when i do so, but when i do ls > test.txt in test.txt there is also test.txt (logical

View 4 Replies View Related

Programming :: Awk Printing From Nth Field To Last Field

Jan 8, 2010

How can print the, let's say 5nd field to the last field of every record (let's say we have 10 fields)?

I mean: I cant avoid to have to do:

print '{$5 $6 $7 $8 $9 $10}'

View 2 Replies View Related

Programming :: Php - Get A Return From A Field Within A Field?

Apr 27, 2009

I am creating a game with random variables. In the game I have created a dialogue exchange to players. I have set up a table with various returns and I inserted {$fields} to represent various random variables. When I call on the requested fields, I only see the field text and my field names. Am I supposed to parse something and call it back another way?

ie: myfield is: "You have won {$random1} silver! <br />{$wi['gender'] majesty rewards you well." the code I am using to call that field is:

View 11 Replies View Related

General :: Getting The Line Of String From Previous Pipe Output By Line Number?

Feb 8, 2010

After running the following command, I get:

[root@yukiko /]# find / -iname .bashrc
/home/clamav/.bashrc
/home/vpopmail/.bashrc
/etc/skel/.bashrc
/root/.bashrc

But I would like to have a command that prints a specific line by supplying the command with the line number, for example:

[root@yukiko /]# find / -iname .bashrc | getline(2)
/home/vpopmail/.bashrc

Is there such a command on CentOS?

View 3 Replies View Related

Programming :: Sed Move To Prev Line If Match

Jan 31, 2010

sed move to prev line if match

file:

desired result:

View 4 Replies View Related

Programming :: Orrect Command To Create A Named Pipe File?

Apr 22, 2010

My question deals with me creating a name pipe (file) in the my /group directory called chat.I then have to write a script to read from the named pipe and save data into a file called chat.log until the words End of File are passed to the program.

-When I created the named pipe file (chat) I used the mknod chat p command..Is this the correct command to create a named pipe file? -Then I'm having trouble with my script and how to make it run until the words End of File are entered in. This is what I have so far.

View 6 Replies View Related

Programming :: Access A File Line By Line, And Check The Length Of Each Line.

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

General :: Command Line - Move Or Copy Selected File

Jul 16, 2011

How do I move around select a file and move or copy it. All tutorials I have seen are not simple enough.

View 7 Replies View Related

Software :: Rear File Names To Creat A Comma Delimited File?

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

Programming :: Concatenate The Output To Comma Delimited?

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

Programming :: Create File Listing In C++ That Will Generate Line Number On Every Line Of Code

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

Programming :: Adding Line From File1 Into A Line Of Another File Based On Maching IDs

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

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 :: Get A Field Value Corresponding To Another Field Value?

Dec 14, 2010

i have a file : file.dat with following data

Code:

STORAGE PERCENTAGE FLAG:

/storage_01 64% 0
/storage_02 17% 1
/storage_03 10% 0
/storage_04 50% 1

I need to get the value of PERCENTAGE in a variable for a value of storage passed as variable i have tried the following without success like :

Code:

percentage='awk -vx="$defaultStorage" '{FS=OFS=" "}$1==x{print $2}1' file.dat

View 2 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 :: Join 5 Lines Blocks Comma Delimited?

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

Programming :: C - Copy File Line By Line With Some Slight Changes?

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

Programming :: Error During Reading A File Line By Line In C?

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

Programming :: QTimer To Read A File Line After Line?

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







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