Sponsored Content
Full Discussion: fields in AWK
Top Forums UNIX for Dummies Questions & Answers fields in AWK Post 302529620 by Aussiemick on Thursday 9th of June 2011 10:46:22 PM
Old 06-09-2011
Awesome, yeah I have a space between the file size (700k) and filename (data_sample1_test) on purpose and hoped that each field was infact each string/delimited by spaces.

Also the reason I used BEGIN was because when I was playing with a Hello World script I came across on wikipedia I took out the BEGIN and somehow created an infinite loop where whenever I typed anything, it would be followed by Hello, World! until I forced a stop.


Thanks very much for the reply alister.

---------- Post updated at 12:46 PM ---------- Previous update was at 11:22 AM ----------

I understand what I did to create this infinite loop thing, as I just tried what you said and it happened again.
Was just a silly mistake on my part, and technically I suppose it's not an infinite loop at all, I'm just outputting the result straight to linux (i think)

So it was literally the difference between giving it a file to access from or not giving it a file
Accessing from data_SAMPLE1_test
Code:
awk ' { print $0 }' data_SAMPLE1_test > new111

Not accessing a file
Code:
awk ' { print $0 }' > new111

I know that must seem extremely stupid and/or simple, but I guess I'm so new to this language it didn't occur to me straight away Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Awk - more than 99 fields?

Just written a great little script that analyses a flat ASCII CSV file and reports for any discrepancies with field counts per record etc. Works fine on all the flat files except one, which has 113 fields per line. AWK can only seemingly cope with up to 99 fields. Is there any way around... (2 Replies)
Discussion started by: DaveM
2 Replies

2. Shell Programming and Scripting

combining fields in awk

I am using: ps -A -o command,%cpu to get process and cpu usage figures. I want to use awk to split up the columns it returns. If I use: awk '{print "Process: "$1"\nCPU Usage: "$NF"\n"}' the $NF will get me the value in the last column, but if there is more than one word in the... (2 Replies)
Discussion started by: json4639
2 Replies

3. Shell Programming and Scripting

Specifying and replacing fields with awk

#cat BATCH007.TXT 01,661060052,061000104,081118,0915,07,80,1,2/ 99,,,2/ I have this file called BATCH007.TXT. I am trying to change fields 2 and 3 on line 2 to have zeroes. Like this: 01,661060052,061000104,081118,0915,07,80,1,2/ 99,0,0,2/ I can use these commands to print identify the... (2 Replies)
Discussion started by: ddurden7
2 Replies

4. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

5. Shell Programming and Scripting

edit fields awk

Hi there, i need some help please... I have this text, it's name data.txt that contains the following information: Mark Owen: 6999999888 6999999888 +302310999999 2310999999 Steve Blade Pit: +30691111222 2310888777 6999999888 John Rose: 2310777555 310544565 +302310999999 Mary Stuart:... (7 Replies)
Discussion started by: Mark_orig
7 Replies

6. Shell Programming and Scripting

No. of Fields using Awk

Hi, Could someone please let me know me how i can use an awk command to print the No. of fields of each file present in a Directory?Suppose the Directory has 5 text files in which the first record in each file contains fields separated by a '|'. I need to use a awk command to display the No... (8 Replies)
Discussion started by: pchegoor
8 Replies

7. Shell Programming and Scripting

Join fields comparing 4 fields using awk

Hi All, I am looking for an awk script to do the following Join the fields together only if the first 4 fields are same. Can it be done with join function in awk?? a,b,c,d,8,,, a,b,c,d,,7,, a,b,c,d,,,9, a,b,p,e,8,,, a.b,p,e,,9,, a,b,p,z,,,,9 a,b,p,z,,8,, desired output: ... (1 Reply)
Discussion started by: aksijain
1 Replies

8. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

9. Shell Programming and Scripting

awk - compare 1st 15 fields of record with 20 fields

I'm trying to compare 2 files for differences in a selct number of fields. When differnces are found it will write the whole record of the second file including appending '|C' out to a delta file. Each record will have 20 fields, but only want to do comparison of 1st 15 fields. The 1st field of... (7 Replies)
Discussion started by: sljnk
7 Replies

10. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies
FSF-FUNDING(7)								GNU							    FSF-FUNDING(7)

NAME
fsf-funding - Funding Free Software DESCRIPTION
Funding Free Software If you want to have more free software a few years from now, it makes sense for you to help encourage people to contribute funds for its development. The most effective approach known is to encourage commercial redistributors to donate. Users of free software systems can boost the pace of development by encouraging for-a-fee distributors to donate part of their selling price to free software developers---the Free Software Foundation, and others. The way to convince distributors to do this is to demand it and expect it from them. So when you compare distributors, judge them partly by how much they give to free software development. Show distributors they must compete to be the one who gives the most. To make this approach work, you must insist on numbers that you can compare, such as, ``We will donate ten dollars to the Frobnitz project for each disk sold.'' Don't be satisfied with a vague promise, such as ``A portion of the profits are donated,'' since it doesn't give a basis for comparison. Even a precise fraction ``of the profits from this disk'' is not very meaningful, since creative accounting and unrelated business decisions can greatly alter what fraction of the sales price counts as profit. If the price you pay is $50, ten percent of the profit is probably less than a dollar; it might be a few cents, or nothing at all. Some redistributors do development work themselves. This is useful too; but to keep everyone honest, you need to inquire how much they do, and what kind. Some kinds of development make much more long-term difference than others. For example, maintaining a separate version of a program contributes very little; maintaining the standard version of a program for the whole community contributes much. Easy new ports contribute little, since someone else would surely do them; difficult ports such as adding a new CPU to the GNU Compiler Collection contribute more; major new features or packages contribute the most. By establishing the idea that supporting further development is ``the proper thing to do'' when distributing free software for a fee, we can assure a steady flow of resources into making more free software. SEE ALSO
gpl(7), gfdl(7). COPYRIGHT
Copyright (c) 1994 Free Software Foundation, Inc. Verbatim copying and redistribution of this section is permitted without royalty; alteration is not permitted. gcc-4.0.1 2009-05-18 FSF-FUNDING(7)
All times are GMT -4. The time now is 08:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy