Sponsored Content
Top Forums Shell Programming and Scripting How to retain blank spaces in AWK? Post 302494212 by bsn2011 on Sunday 6th of February 2011 08:04:55 AM
Old 02-06-2011
Hi all,
thanks for your replies. In my previous message i actually used some data to explain my problem but i did not actually posted the original data that i am having problem with it. I have attached the origional file to this message. in this file i have monthly temperature data with 13 columns where ist colums is daya and other 12 cols are months. the problem i am having is that this file is not comma delimited file and for the months with 28 or 30 days, i have blank spaces at the end. if I use this command to read the file
Code:
 
awk -F" " '{$1=$1;print}' ASTMAX91.TXT

then i got the following output where the position of the data is disturbed after 28 days due to these spaces between columns.

Code:
 
JAN FEB MAR APR MAY JUN JULY AUG SEP OCT NOV DEC
DATE -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- ------------
1 3.4 5.1 5.6 14.1 21.2 20.9 26.7 29.2 26.7 19.2 13.7 8.4
2 1.2 2.8 3.8 13.9 11.4 22.9 25.6 27.8 25.9 18.9 13.9 6.7
3 -2.2 3.4 1.2 14.1 12.0 24.5 28.4 25.6 28.0 21.2 14.5 7.3
4 -3.3 3.9 7.6 15.4 15.3 26.2 25.1 28.4 28.8 22.0 14.6 4.7
5 -1.1 0.3 2.4 15.8 12.9 26.2 23.9 20.8 29.6 22.3 15.6 6.7
6 0.1 0.6 3.1 16.9 13.5 27.0 25.8 28.4 29.0 19.5 15.1 10.1
7 0.3 0.8 2.5 16.8 18.2 28.4 18.4 29.2 30.2 21.2 15.1 7.6
8 -1.9 2.3 6.9 12.9 17.3 26.9 17.8 31.2 26.2 17.8 15.6 4.5
9 4.4 4.4 5.2 8.4 15.2 29.0 26.2 27.8 26.9 14.5 13.4 4.8
10 0.1 4.5 6.9 10.1 13.9 28.2 25.9 21.2 28.0 19.5 13.4 7.8
11 -0.5 3.3 5.6 12.6 17.8 26.2 28.4 15.9 28.5 19.5 12.3 7.8
12 -3.8 3.4 3.7 13.4 18.6 21.3 29.3 23.9 29.1 16.4 12.8 7.8
13 1.3 4.2 3.9 13.7 20.3 27.6 25.1 26.6 29.0 15.6 11.2 3.8
14 -3.3 1.1 7.4 12.6 20.3 27.3 18.9 28.7 30.3 15.1 12.8 6.3
15 -3.3 1.8 5.3 10.6 20.4 29.0 18.9 30.6 28.9 17.3 10.1 8.1
16 0.1 2.1 6.3 5.2 20.6 29.2 24.5 30.3 27.3 13.7 10.3 6.9
17 -2.7 -0.4 10.3 8.7 18.1 28.3 27.3 28.9 27.3 12.3 10.1 9.6
18 2.3 1.4 7.9 10.4 22.0 24.7 30.1 29.1 17.8 15.2 8.9 12.3
19 0.3 3.1 2.0 11.7 22.3 22.8 28.2 29.5 18.9 16.8 10.6 10.2
20 3.4 3.4 8.1 14.2 18.5 15.1 28.6 31.3 17.8 17.0 9.2 8.7
21 0.1 5.6 9.5 16.2 14.5 18.9 30.1 28.4 19.6 16.7 11.2 5.3
22 2.8 6.7 11.0 15.6 12.3 22.2 25.3 23.7 21.7 15.1 13.4 2.6
23 0.6 8.1 6.7 10.6 17.0 21.7 19.5 20.8 21.7 18.1 12.3 5.6
24 0.1 8.4 10.6 11.7 15.2 24.1 24.5 23.4 22.6 18.1 10.1 2.9
25 1.7 6.7 8.9 17.4 16.9 24.5 26.7 26.2 23.6 15.6 10.9 1.7
26 1.7 4.5 9.9 17.3 7.7 23.7 19.5 27.0 22.8 15.6 8.9 1.2
27 2.8 6.8 13.4 17.9 14.1 25.1 25.1 28.1 18.9 18.7 7.3 5.1
28 6.3 6.4 12.3 17.4 19.1 25.7 28.1 29.0 15.4 15.6 4.7 1.2
29 5.6 14.3 19.6 19.2 27.3 28.4 29.0 17.8 13.9 7.8 2.8
30 7.6 15.2 20.3 19.9 27.0 29.5 25.1 18.9 13.9 8.4 2.6
31 3.9 16.4 19.1 30.1 24.5 14.7 2.3

i really appreciate your help. i have 100 of file to process.
Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

howtodelete blank spaces

sry im new to this...another qns.. if i have a line in the normal shell the file is email.scp. it contains a txt file eg hello.txt that contain this infomation. k@hotmail.com j@jotm.com how do i delete away the blank spaces after the k@hotmail.com..i dun wan any blank spaces after the... (2 Replies)
Discussion started by: forevercalz
2 Replies

2. Shell Programming and Scripting

blank spaces getting deleted

I have to filter out data from a file based on the value of first three characters of each record I have used the following logic FIN=$LOC/TEST2.TXT FEEDFILE=$LOC/TEST1.TXT while read FDROW do FEEDROW=$FDROW; DTYPE=`echo $FEEDROW |cut -c 1-3` if ; then echo $FEEDROW >> $FIN... (5 Replies)
Discussion started by: gander_ss
5 Replies

3. UNIX for Dummies Questions & Answers

string with blank spaces

I have a file that has dates like this: date FINAL_RESULT; 7 date FINAL_RESULT; 2 date FINAL_RESULT; 5 With this command: seira=`cut -f2 -d\; tes.txt` i take the date FINAL RESULTs and i store them on variable seira.then seira look like this: 6 3 8 I want to read seira and make a sum of all... (4 Replies)
Discussion started by: psalas
4 Replies

4. Shell Programming and Scripting

how to remove blank spaces of a file with awk??

hello how to remove blank spaces of a file with awk?? i´m trying awk '{gsub(" ","",$0); print $0;}' filename.txt but it answers syntax error near line first of all i did this for download from netbackup database jobs privilege bpdbjobs -report -M sv88 -gdm -header |cut -c-1024... (4 Replies)
Discussion started by: pabloli150
4 Replies

5. Shell Programming and Scripting

Handling blank spaces

Hi, I am trying to replace a specific column values in a csv file with double quotes when I am find embedded spaces with in the fields. Example: SNO,NAME,ZIPCODE,RANK,SEX,ADDRESS 1,Robert,74538,12,34, M,Robert Street, NY 2,Sam,07564,13,M,12 Main Ave, CA 3,Kim, Ed,12345,14,M,123D ,... (1 Reply)
Discussion started by: techmoris
1 Replies

6. Shell Programming and Scripting

Removing blank spaces, tab spaces from file

Hello All, I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out. My file is like this (<b> means one blank space, <t> means one tab space)- $ cat file NARESH<b><b><b>KUMAR<t><t>PRADHAN... (3 Replies)
Discussion started by: NARESH1302
3 Replies

7. Shell Programming and Scripting

Problems with Blank Spaces

Hi to all. How can I pass to the stat command a file path with blank spaces? And another question, if I use stat command like this: stat / -name "*.sh" -user $user_name -exec stat -c %n%x {} \; How can I get the result with a ":" into the name of the file and the time of the last... (4 Replies)
Discussion started by: daniel.gbaena
4 Replies

8. Shell Programming and Scripting

Remove blank spaces

Gents, Please can you help me.. to remove blank spaces :) Input ABSOLUTE , ,FALSE ,1035 ,28 ,669 ,1817.0 ,CORREL BEFORE ,1 ABSOLUTE , ,FALSE ,1035 ,28 ,686 ,1817.0 ,CORREL BEFORE ,1 ABSOLUTE , ,FALSE ,1035 ,28 ,670 ,1819.0 ,CORREL BEFORE ,1 ABSOLUTE , ,FALSE ... (4 Replies)
Discussion started by: jiam912
4 Replies

9. UNIX for Dummies Questions & Answers

Remove blank spaces

Dear Masters, I want to remove all lines with blank spaces input file: a|abc|0|1 a|abc|2|3 b||3|5 c|def||7 d|def|0|1 Expected: a|abc|0|1 a|abc|2|3 d|def|0|1 I did this awk -F'|' '!/^$/' input (4 Replies)
Discussion started by: radius
4 Replies

10. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies
ARBITRON(8)						      System Manager's Manual						       ARBITRON(8)

 *

NAME
arbitron - arbitron mailboxes SYNOPSIS
arbitron [ -C config-file ] [ -o ] [ -u ] [ -l ] [ -p months ] [ -d days | -D mmddyyyy[:mmddyyyy] ] mailbox... DESCRIPTION
Arbitron collects and reports readership statistics for mailboxes on the server. It also optionally prunes the mailboxes of Seen state for dormant users. Arbitron produces one line of output per mailbox, reporting the mailbox name followed by a space, followed by the number of readers (and if -u is specified, followed by a colon and a comma-separated list of the readers userids), and if -o is not specified, another space and the number of subscribers (and if -u is specified, followed by a colon and a comma-separated list of the subscribers userids). IMPORTANT: This format is subject to change in future versions. Each "reader" is a distinct authentication identity which has "s" rights to the mailbox and which has SELECTed the mailbox within either the past days days or the specified date range. Users are not counted as reading their own personal mailboxes. Personal mailboxes are not reported unless there is at least one reader other than the mailboxes owner. Arbitron reads its configuration options out of the imapd.conf(5) file unless specified otherwise by -C. OPTIONS
-C config-file Read configuration options from config-file. -o "old way" -- do not report subscribers. -u Report userids in addition to the count(s). -l Enable long reporting (comma delimited table consisting of mbox, userid, r/s, start time, end time). -d days Count as a reader an authentication identity which has SELECTed the mailbox within days days. Default is 30. -D mmddyyyy[:mmddyyyy] Count as a reader an authentication identity which has SELECTed the mailbox within the given date range. The start date and optional end date are specified as 2-digit month of the year, 2-digit day of the month, and 4-digit year. If the end date is not specified, then the current system time is used as the end time. -p months Prune Seen state for users who have not SELECTed the mailbox within months months. Default is infinity. FILES
/etc/imapd.conf CMU
Project Cyrus ARBITRON(8)
All times are GMT -4. The time now is 09:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy