Sponsored Content
Top Forums Shell Programming and Scripting Search for a particular field length and append '0' if less less than 10 Post 302655005 by alister on Tuesday 12th of June 2012 02:42:15 PM
Old 06-12-2012
Quote:
Originally Posted by Lem
Without awk (just for the sake of curiosity), and in pure bash, maybe something like...
Keeping with that spirit, here's one in sh:
Code:
while IFS=\| read -r x y z; do
    while [ ${#y} -lt 10 ]; do
        y=${y}0
    done
    printf '%s|%s|%s\n' "$x" "$y" "$z"
done

Welcome to the forum, Lem.

Regards,
Alister
These 2 Users Gave Thanks to alister For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with finding length of a field

I have a pipe delimited file. I need to check that the first and second fields are 5 characters long and if not i need to append 0 in front of them to make them 5 characters long. can some body let mwe know how i can find the length of the two fields and then make them 5 characters long if they... (6 Replies)
Discussion started by: dsravan
6 Replies

2. Shell Programming and Scripting

Awk Search text string in field, not all in field.

Hello, I am using awk to match text in a tab separated field and am able to do so when matching the exact word. My problem is that I would like to match any sequence of text in the tab-separated field without having to match it all. Any help will be appreciated. Please see the code below. awk... (3 Replies)
Discussion started by: rocket_dog
3 Replies

3. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

4. Shell Programming and Scripting

Append spaces the rows to make it into a required fixed length file

I want to make a script to read row by row and find its length. If the length is less than my required length then i hav to append spaces to that paritucular row. Each row contains special characters, spaces, etc. For example my file contains , 12345 abcdef 234 abcde 89012 abcdefgh ... (10 Replies)
Discussion started by: Amrutha24
10 Replies

5. Shell Programming and Scripting

Replace a field with a character as per the field length

Hi all, I have a requirement to replace a field with a character as per the length of the field. Suppose i have a file where second field is of 20 character length. I want to replace second field with 20 stars (*). like ******************** As the field is not a fixed one, i want to do the... (2 Replies)
Discussion started by: gani_85
2 Replies

6. Linux

Bash to append domain in search field of resolv.conf after vpnc connection in Linux

After vpn connection,I am not able to resolve any machines in remote gateway.It looks like remote domain is added to domain field instead of adding it to the Search field in /etc/resolv.conf I want the remote domain to add to search field along with local domain.Can anyone tell a bash or script... (2 Replies)
Discussion started by: jeremy_brett
2 Replies

7. UNIX for Dummies Questions & Answers

To flat file, append null or space if its length is less than 10

Hi, We receive flat files with fixed width data Now our goal is append from right null or space to each record if the lenght of the record is less than for example 10. for example 123 45 6 0 123 45 123 45 6 123 and output should be 123 45 6 0 123 45**** 123 45 6**... (7 Replies)
Discussion started by: shharrath
7 Replies

8. Shell Programming and Scripting

Append 0's based on length

I'm having data like this, "8955719","186497034","0001","M","3" "8955719","186497034","0002","M","10" "8955719","186497034","0003","M","10" "8955719","186497034","0004","M","3" "8955723","186499034","0001","M","3" "8955723","186499034","0002","M","10" "8955723","186499034","0003","M","10"... (3 Replies)
Discussion started by: Artlk
3 Replies

9. What is on Your Mind?

Updated Forum Search Index Min Word Length to 2 Chars and Added Quick Search Bar

Today I changed the forum mysql database to permit 2 letter searches: ft_min_word_len=2 I rebuilt the mysql search indexes as well. Then, I added a "quick search bar" at the top of each page. I have tested this and two letter searches are working; but it's not perfect,... (1 Reply)
Discussion started by: Neo
1 Replies
GIF2TIFF(1)						      General Commands Manual						       GIF2TIFF(1)

NAME
gif2tiff - create a TIFF file from a GIF87 format image file SYNOPSIS
gif2tiff [ options ] input.gif output.tif DESCRIPTION
Gif2tiff converts a file in the GIF87 format to TIFF. The TIFF image is created as a palette image, with samples compressed with the Lem- pel-Ziv & Welch algorithm (Compression=5). These characteristics can overriden, or explicitly specified with the options described below. OPTIONS
-c Specify a compression scheme to use when writing image data: -c none for no compression, -c packbits for the PackBits compression algorithm, -c zip for the Deflate compression algorithm, and -c lzw for Lempel-Ziv & Welch (the default). -r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approxi- mately 8 kilobytes. NOTES
The program is based on Paul Haeberli's fromgif program which, in turn, is based on Marcel J.E. Mol's GIF reader. BUGS
Should have more options to control output format. SEE ALSO
pal2rgb(1), tiffinfo(1), tiffcp(1), tiffmedian(1), libtiff(3) October 15, 1995 GIF2TIFF(1)
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy