Sponsored Content
Full Discussion: Format problems with fields
Top Forums UNIX for Advanced & Expert Users Format problems with fields Post 302332952 by talk2pawee on Friday 10th of July 2009 12:46:39 PM
Old 07-10-2009
Format problems with fields

The following output has a space as the Field Separator.

I need:

$1 Set the field width to 15 then zero-fill to the right.
$6 Set the field width to 15 then zero-fill to the left.

Code:
01-10016 1000 MV010 20090708 12003 $NK0015101 01
01-100161 12000 MV070 20090708 12003 $NK0015201 01
01-100162 10000 MV010 20090708 12003 $NK0015301 01
01-100163 200 MV010 20090708 12003 $NK0015401 01
01-100165 1200 MV003 20090708 12003 $NK0015501 01

Both fields in the input file are strings.

Thanks,
Pawee

Last edited by vgersh99; 07-10-2009 at 02:03 PM.. Reason: code tags, PLEASE!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

mail format problems

Hi, I have a script that runs off the cron and creates a report, carries out a few checks and then sends the info in a email (i'm using mailx). To exectute the sending from the script all I do is, cat $reportfile | mailx -s "The Subject" my.email@work.com When I test running this... (4 Replies)
Discussion started by: nhatch
4 Replies

2. 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

3. Shell Programming and Scripting

awk,cut fields by change field format

Hi Everyone, # cat 1.txt 1321631,77770132976455,19,20091001011859,20091001011907 1321631,77770132976455,19,20091001011859,20091001011907 1321631,77770132976455,19,20091001011859,20091001011907 # cat 1.txt | awk -F, '{OFS=",";print $1,$3,$4,$5}' 1321631,19,20091001011859,20091001011907... (7 Replies)
Discussion started by: jimmy_y
7 Replies

4. Shell Programming and Scripting

Using sed to format several fields

I have data that is tab delimited and looks like: /dev/dsk/c0t0d0s1 - - swap - no - /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no - /dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr ufs 1 no -... (5 Replies)
Discussion started by: bradg
5 Replies

5. Shell Programming and Scripting

Format Fields

I have a CSV file like this: abc ,def ghi ,jkl mno ,pqr stu ,vwx Desired Output: Field 1: abc mno Field 2: def ghi pqr stu Field 3: jkl vwx This does not work: for i in `cat file.txt` do Field1=`echo $i | awk -F ',' '{print $1}'| sed 's/^ *// ; s/ *$//'`... (8 Replies)
Discussion started by: shellguy
8 Replies

6. UNIX for Dummies Questions & Answers

STDOUT redirect to file and format problems

Hi All, I am using centOS. When I try to redirect STDOUT to a file, it ends up in getting some funny characters. For example ... STDOUT of the command as follows. $ ls H3k27me3 H3k36me3 H3k4me1 H3k4me2 H3k4me3 H3k9ac H4k20me1 $ ls >test $ cat test ^ (1 Reply)
Discussion started by: Chulamakuri
1 Replies

7. Shell Programming and Scripting

awk - problems by converting date-format

Hi i try to change the date-format from DD/MM/YYYY into MM/DD/YY. Input-Data: ... 31/12/2013,23:40,198.00,6.20,2,2,2,1,11580.0,222 31/12/2013,23:50,209.00,7.30,2,2,3,0,4380.0 01/01/2014,00:00,205.90,8.30,2,2,3,1,9360.0,223 ... Output-Data should be: ...... (7 Replies)
Discussion started by: IMPe
7 Replies

8. 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

9. Shell Programming and Scripting

awk to format file and combine two fields using comma

I am trying to use awk to format the file below, which is tab-delimited. The desired out is space delimited and is in the order of $9 $13 $2 $10-$11.$10 and $11 are often times multiple values separated by a comma, so the value in $10 is combined with the first value from $11 using the comma.... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
IMAGEFILLEDELLIPSE(3)							 1						     IMAGEFILLEDELLIPSE(3)

imagefilledellipse - Draw a filled ellipse

SYNOPSIS
bool imagefilledellipse (resource $image, int $cx, int $cy, int $width, int $height, int $color) DESCRIPTION
Draws an ellipse centered at the specified coordinate on the given $image. PARAMETERS
o $ image -An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(3). o $cx - x-coordinate of the center. o $cy - y-coordinate of the center. o $width - The ellipse width. o $height - The ellipse height. o $color - The fill color. A color identifier created with imagecolorallocate(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 imagefilledellipse(3) example <?php // create a blank image $image = imagecreatetruecolor(400, 300); // fill the background color $bg = imagecolorallocate($image, 0, 0, 0); // choose a color for the ellipse $col_ellipse = imagecolorallocate($image, 255, 255, 255); // draw the white ellipse imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse); // output the picture header("Content-type: image/png"); imagepng($image); ?> The above example will output something similar to:[NOT DISPLAYABLE MEDIA]Output of example : imagefilledellipse() NOTES
Note This function requires GD 2.0.1 or later (2.0.28 or later is recommended). SEE ALSO
imageellipse(3), imagefilledarc(3). PHP Documentation Group IMAGEFILLEDELLIPSE(3)
All times are GMT -4. The time now is 05:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy