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


ADVERTISEMENT

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 :: 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 :: Field-terminating Char Appears Within Field Values?

May 18, 2010

I've had a very colorful morning learning the innerparts of Linux's sort command, and have come across yet another issue that I can't seem to find an answer for in the documentation. I'm currently using -t, to indicate that my fields are split by the comma character, but I'm finding that in some of my files, the comma is used (between double-quotes) within values:

Jonathan Sampson,,foo@bar.com,0987654321
"Foobar CEO,","CEO,",ceo@foobar.com,,

How can I use a comma to terminate my fields, but ignore the occurences of it within values? Is this fairly simple, or do I need to re-export all of my data using a more-foreign field-terminator? (Unfortunately, I do not have any control over declaring a different terminator with this particular project).

View 2 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 :: Form Field Validation Using PHP

Sep 10, 2009

I want to validate a web form using PHP. I spent ages confusing myself with client side scripting and realised until I worked out it is not what I want. My problem is that now I am looking at PHP and everything is mixed up in my brain. I need to point out that PHP is very new to me! This is what I already have:
1 An html page with my form on it.
2 PHP page which emails the contents of the form to me.

The above works well. For the sake of clarity, here are my pages (cut down to the essentials where appropriate): My html form:
first name surname
Email  
Home phone
Mobile
Work phone

I have read and understood your terms and conditions. My php script (regform.php)
$receiver = 'me@email'; $subject = 'New registration'; #$message = 'This is a new registration.'; $surname = $_POST['surname']; $firstname = $_POST['firstname']; $address = $_POST['address']; $email = $_POST['email']; $homeph = $_POST['homeph']; $mobileph = $_POST['mobileph']; $workph = $_POST['workph']; $time = $_POST['time']; #from here $oldaddress = $_POST['oldaddress']; $DOB = $_POST['DOB']; $elect = $_POST['elect']; $job = $_POST['job']; $salary = $_POST['salary']; $employer = $_POST['employer']; $benefit = $_POST['benefit']; $smoke = $_POST['smoke']; $claim = $_POST['claim']; $children = $_POST['children']; $children2 = $_POST['children2']; $pets = $_POST['pets']; $pets2 = $_POST['pets2']; $require = $_POST['require']; $terms = $_POST['terms']; $rooms = $_POST['rooms']; $body = "first name:$firstname
surname:$surname
DOB:$DOB
email:$email
home phone:$homeph
mobile phone:$mobileph
work phone:$workph
address:
$address
time at this address:$time
previous address:$oldaddress
electoral register:$elect
employment:$job
employer:$employer
salary:$salary
benefit claim:$benefit
future benefit:$claim
children:$children
ages:$children2
pets:$pet
pet type:$pets2
other requirements:$require
terms:$terms"; $headers = 'From: email' . "
" . 'Reply-To: email "
" . 'X-Mailer: PHP/' . phpversion(); mail($receiver, $subject, $body, $headers, "From: $firstname $surname
" . "Reply-To: $firstname $surname class="inlineimg" />;

You can see there are many more form fields than I have shown in my example html form above. What I want is that the following fields have to be filled:
1 mobileph
2 email
3 terms (checkbox)
I would like the user to be asked to fill the form in properly if any/all of the 3 fields have not been filled in. I imagine I need some php in the html page and some more in the php page. I am certainly not asking any one to do this for me but I am really confused. I have googled and copied and pasted and edited for 6 hours and I am lost. What I want is a very simple and clear example of the code needed. Sorry if I sound as if I can't search properly on Google: in this case I clearly can't!

View 2 Replies View Related

Programming :: SQL -any Value For Numeric Or String Field?

Feb 12, 2010

how do i ask in a query for any numeric or string field? It may not have any meaning, but i need it to fill a toplink DataReadQuery in java....Something like " select * from table where table.fieldA='?'

View 2 Replies View Related

Programming :: Getting A Particular Field Replaced In A Host List?

Sep 30, 2010

I'm having a bit of a trouble getting a particular field replaced in a host list. I have a MasterHostList which has a comma delimiter for fields and a new line to separate servers.

server1,random,random,group1,random,random
server2,random,random,group1,random,random

I then have a file.list file with a grouping of server names. What I need is to search the MasterHostList and for each server that is in the file.list I need to change the fourth field from group1 to group2 without changing the order or position of anything in the MasterHostList. Obviously the above names are arbitrary.

Failed attempts have been: for SERVER in `cat file.list`; do sed /$SERVER/s/,group1,/,group2,/ MasterHostList MasterHostList.tmp && mv -f MasterHostList.tmp MasterHostList; done for SERVER in `cat file.list`;do awk 'BEGIN { FS=OFS="," } /^${SERVER}/ { $4 = "group2" } 1' ./MasterHostList MasterHostList.tmp && mv -f MasterHostList.tmp MasterHostList; done

Both of these would in various output tests find the correct lines, but it wouldn't change them all correctly.

View 3 Replies View Related

Programming :: Find A Field And Print Its Companion?

Apr 5, 2010

I have a file with variable length lines containing fields separated by colons:

Code:
path/to/file0.c:4150:109:4151:142:4153:275
path/to/file1.c:4040:109
path/to/file2.c:4605:72:4606:109
path/to/file3.c:4380:54

The first field identifies the file name, the second is the search key, and the third is the line number of the file that the search key points to. Any subsequent fields are other key/line number pairs.

As an example, I can search for 4151 (key) from my bash script to identify the file I will have to access, but I also need to capture the line (142) as well, and I can't figure out how to do that using grep, awk or sed (or anything else).

View 2 Replies View Related

Programming :: How To Do Fuzzy Matching On A MySQL Field

Feb 18, 2011

If I have a MySQL field called, say, "Occupation", which contains "Java Programmer" in it, I would like it to come up when I search for "Java", so that I can get to the other fields in the table.
How do I do this?

View 2 Replies View Related

Programming :: MySQL Year Field Range Too Limited

Jul 1, 2011

In the MySQL database for one of my programming projects, I used a "YEAR(4)", because I wanted the column to contain four-digit year values. I discovered, though, that this type only allows values from 1901 to 2155, which is not workable as some year values are previous to the twentieth century. But I do not want a "DATE" type because the month and day are of no interest to me. What type should I convert to that would be the least radical change in data type, while giving more range?

View 1 Replies View Related

Programming :: Place Another Command Like Grep Or Cut In Address Field?

Jan 28, 2010

The thing is that the command for sed resembles the following

[code]...

Now if I want to place another command like grep or cut in the address field how do I do it. Actually I don't know the line number. The user has to give it as an input. How shall I do that?

View 8 Replies View Related

Programming :: Converting Date Format In A Comma Separated Field?

Apr 9, 2010

I am in the process of learning some scripting, however I am running into a roadblock in specifying a certain time format in the array. Ideally I would like to use Here are the lines of text that I am interrogating:

1123,3/25/2010,00:14 Thu,33229
1124,3/26/2010,13:30 Fri,33230
1125,3/27/2010,04:49 Sat,33231

[code]...

View 2 Replies View Related

Programming :: Parsing VoIP Call Detail Records (Field Format)

Jan 4, 2010

I am going to parse the Cisco voip CDR(Call Detail Records), please tell me the field format of the CDR files.

View 1 Replies View Related

Programming :: Equivalence Classes Based On Field Values And Multi-key Hashtable?

May 12, 2010

I've got a set of objects (all of the same type). I'm trying to think of a good way to divide it into equivalence classes, with equivalence of two objects defined as meaning a specified set of attributes are equal for both objects. More concretely, I've got:

- a Java class with around 50 fields
- a bunch of instances of the class

I want:

- to divide the instances into a few sets
- in each set, each instance has field 1 - field 5 equal to fields 1-5 of the other instances in the set.

The method I've come up with is to generate a hashcode for each instance based on the hashcodes of fields 1-5*, and map the hashcode to one of my sets. Ignoring problems with potential hashcode collisions (which I'm expecting to be too rare to worry about for now), does that sound reasonable? It seems simple enough, but I'm wondering if there's a simpler method I haven't thought of.

* I'll generate the hashcode using a method based on Eclipse's generic hashcode method, which looks like this:

Code:

public int hashCode() {
final int prime = 31;
int result = 1;

[code]....

View 5 Replies View Related

Programming :: Helios : Using Tab On Text Field Having Content Proposals, Crashes Application?

Sep 8, 2010

Using content proposal in helios, giving problem if u press tab. Below is the error. For recreation snippet is provided(taken from 2 sites) after error log.Only u need to press tab while proposal pop up is visible & then point mouse at client.

#################################ERROR LOG#############################
# A fatal error has been detected by the Java Runtime Environment:
#

[code]....

View 9 Replies View Related

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

Programming :: Script To Delete Aligned Single-character Columns With No Field Separator?

Apr 20, 2010

The lines beginning with greater-than symbols are the sequence descriptors and the lines immediately after each descriptor with A-Z characters, dashes, and question marks are the aligned DNA sequences. The sequences are always the same length within a file and never span/wrap across more than one line.I am trying to write a script to remove positions in the sequences that are only represented by a -, X, ?, or N (these represent gaps or missing data). Also, if there is exactly one non-gap/missing character in a position it is also useless (there is nothing to compare it to) so I would like to remove those positions as well.

Position 5 (from the left) was removed because it was all gap/missing characters. Position 9 was removed because only one character was a non-gap/missing character. Position 10 was retained because there were 2 non-gap/missing characters.I'm really not sure where to start here. My first concern is I can't figure out how to tell awk to treat each character in lines not containing a greater-than symbol as a separate field. After that, I'm thinking I should use set up a counter to count the number of lines with gap/missing characters comparing that to the total number of lines not containing greater-than signs?

View 14 Replies View Related

Programming :: Length Of "Options" Field In TCP Header Is Floating?

May 31, 2011

As you know, the length of "Options" field in TCP header is floating. It may be from 0 to 40 bytes. Is there any (simple) way to find it or to send data with TCP headers of fixed length?

View 8 Replies View Related

General :: Keep Last 'n' Characters Of A Specified Field?

Apr 4, 2010

The input file consists of several fields. The first field is always five or more characters long. I want to keep the last five characters of the first field.

Example:
If the input file record is FEDERAL PACIFIC ELECTRIC PRODUCTS then I want to keep DERAL I can do this in four steps by using C, REV, C, and REV again but that seems like doing an easy thing the hard way. Is there a straightforward way to achieve this result with C or some other command?

View 14 Replies View Related

General :: Is Field BusID Necessary In XF86Config?

Mar 1, 2011

I am using a cluster of machines running on Ubuntu 10.04 LTS which are supposed to be homogeneous, but apparently they are not. In particular, I am configuring the X server on these machines.The problem is that the BusID of the graphic card is PCI:5:0:0 for some machines, and PCI:3:0:0 for others. Is there a way that the X server automatically detects the appropriate Device (based on the name for instance)?

View 1 Replies View Related

General :: Add Second Field Of Two Files On Different Servers?

Sep 1, 2010

I have one file placed at one server whose sample as follows:

57272 28
56767 0
57575 4

[code]...

View 13 Replies View Related

General :: Merge 2 Files With AWK By The Field Value

Jun 1, 2010

i have 2 file and want to merge them in the first one. the first file is like this:

2 word1
1 word2
6 word3
2 word4
......

the second:

word1 :file1 :file2
word2 :file6
word3 :file1 :file2 :file2 :..up to file6
word4 :file7 :file1
.......

So i want to ADD all those File fiels Wich have different FN for every record.

View 8 Replies View Related

General :: Replicate A Specific Field?

Apr 24, 2010

I have a file containing text. I want to replicate a specific field.For example, I might want to append a copy of the second word of each line to the end of that line.Have: Once upon a midnight dreary, while I pondered weak and weary,Over many a quaint and curious volume of forgotten lore, Want: Once upon a midnight dreary, while I pondered weak and weary, upon Over many a quaint and curious volume of forgotten lore, many Is there a Linux command which will do this? I seek a basic command, not awk, not Perl, because I haven't learned those things yet.

View 14 Replies View Related

Software :: Command To Print The Last Field?

Dec 29, 2010

Is there a way to extract the last field? Specifying the field number is causing problems using awk or cut as the input log file has the output specified in different lines at different places/fields. The only thing constant is the 'pathname' which always occurs at the end.

View 3 Replies View Related

OpenSUSE :: Scrolling In Text Field In Chromium?

Dec 14, 2010

I'm using Chromium 10 from the build service and just installed the upgrade to version 10. Now there seems to be an issue with scrolling. When i go to reply to an email in gmail there is something weird when i try to scroll. The scrollbar will move like i am scrolling but nothing actually in the text area moves

View 9 Replies View Related

Ubuntu Multimedia :: Set ID3 Genre Field To Podcast?

Jun 27, 2010

Set ID3 genre field to podcast?

View 2 Replies View Related

Ubuntu :: OpenOffice. Can't Edit Text Field?

Nov 5, 2010

I use Ubuntu 10.04 and OpenOffice 3.2.We have forms we use for computers we sell. I have to fill out a profile. The problem is I cannot enter text into the text entry fields. I get this error:"Readonly content cannot be changed. No modifications will be accepted."Here is a link to one of the files. If you try to enter more that a digit or two in a text field, you get that error:[URL]

View 9 Replies View Related

Ubuntu Networking :: Use Variables In The Url Field In Firefox?

Mar 27, 2011

"Once upon a time", I think heard of a way to use variables in the url field in firefox(or maybe it was ubuntu in general?).Anyways, if one would type, for instance, "google pokemon," the url would be changed to

View 2 Replies View Related

Ubuntu :: Field 'struct' Has Incomplete Type

May 13, 2011

I'm building a symbol table and syntax tree using lex and yacc for a compiler.

I am stuck with an error for too long. I have defined two structures (one for Symbol Table and another for Syntax Tree).

Code:
typedef struct symbolTable{
char name[30];
.....
struct symbolTable *next;

[Code]......

here's the error:

bottomup.y:76: error: field 'info' has incomplete type.

I tried to define the structure definitions in a separate header file and included in .y file but it didn't work out.

I'm trying to get this done ASAP.

View 1 Replies View Related







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