Generate 100 Character Fixed Length Empty File


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Generate 100 Character Fixed Length Empty File
# 1  
Old 02-02-2011
Generate 100 Character Fixed Length Empty File

Hello Everyone,

I'm running AIX 5.3 and need to generate a 100 character fixed length empty file from within a bash script that I am developing.

I searched and was able to find:

Code:
dd if=/dev/zero of=/test/path/file count=100

however my understanding is that this will generate a file of a fixed size which will not actually be equal to a 100 character file.

Any suggestions?

Thanks in Advance.
-JVT
# 2  
Old 02-02-2011
Another way could be something like:
Code:
awk 'BEGIN{printf("%100s","")}' > /test/path/file

# 3  
Old 02-02-2011
Thanks that seems to be exactly what I needed!
# 4  
Old 02-02-2011
One way to correct the dd:
Code:
dd if=/dev/zero of=/test/path/file bs=100 count=1

# 5  
Old 02-02-2011
alternatively
Code:
dd if=/dev/zero of=/test/path/file bs=1 count=100

# 6  
Old 02-02-2011
Or, any of the following, lol

Code:
dd if=/dev/zero of=/test/path/file bs=50 count=2
dd if=/dev/zero of=/test/path/file bs=25 count=4
dd if=/dev/zero of=/test/path/file bs=20 count=5
 
dd if=/dev/zero of=/test/path/file bs=10 count=10
 
dd if=/dev/zero of=/test/path/file bs=2 count=50
dd if=/dev/zero of=/test/path/file bs=4 count=25
dd if=/dev/zero of=/test/path/file bs=5 count=20

# 7  
Old 02-03-2011

What do you mean by "an empty file"? If it is 100 characters or bytes long, it is not empty.

To fill it with spaces, you don't need any external command:
Code:
printf "%100s" ' ' > "$file"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate fixed length txt file

hi, i am using below query to generate the fixed length txt file. this sql is being called from shell script. This is supposed to be a fixed record file with the below definitions. There must be 2 byte filler after the CAT_ID AND each line should have total of 270 bytes. field ... (1 Reply)
Discussion started by: itzkashi
1 Replies

2. Shell Programming and Scripting

Fixed length to delimited file conversion

Hi All, I need to convert a fixed length file to a delimited file with , (comma). But not all columns, some of the columns in the fixed files are used as fillers and I do not need that in the output file. test_fixed_len.txt I 0515 MR 394 I 0618 MR & MRS 942 I 0618 MR & MRS... (7 Replies)
Discussion started by: member2014
7 Replies

3. Shell Programming and Scripting

Replace and Increment a value in the fixed length file

Hi Everyone, I need to increment a value in the fixed length file. The file has almost a million rows. Is there any easy way to accomplish this. Ex input file ASDSD ADSD 00000 X AAASD ADSD 00000 X SDDDD ADSD 00000 X Ouput ASDSD ADSD 00001 X AAASD ADSD 00002 X SDDDD ADSD 00003 X ... (7 Replies)
Discussion started by: saratha14
7 Replies

4. UNIX for Dummies Questions & Answers

Length of a fixed width file

I have a fixed width file of length 53. when is try to get the lengh of the record of that file i get 2 different answers. awk '{print length;exit}' <File_name> The above code gives me length 50. wc -L <File_name> The above code gives me length 53. Please clarify on... (2 Replies)
Discussion started by: Amrutha24
2 Replies

5. Shell Programming and Scripting

how to read fixed length flat file....

Hi Gurus, Thanks in advance... I am new to writing shell scripting and help me out reading a flat file with fixed length. I have a fixed length flat file with storename(lenth 6) , emailaddress(lenth 15), location(10). There is NO delimiters in that file. Like the following str00001.txt... (2 Replies)
Discussion started by: willywilly
2 Replies

6. UNIX for Dummies Questions & Answers

Convert a tab delimited/variable length file to fixed length file

Hi, all. I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file: 10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783 19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657 And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies

7. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

8. Shell Programming and Scripting

print a file with one column having fixed character length

Hi guys, I have tried to find a solution for this problem but couln't. If anyone of you have an Idea do help me. INPUT_FILE with three columns shown to be separated by - sign A5BNK723NVI - 1 - 294 A7QZM0VIT - 251 - 537 A7NU3411V - 245 - 527 I want an output file in which First column... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

9. Shell Programming and Scripting

Manipulating a fixed length file w/o PERL

Greetings, I need to take a fixed length file, similar to the following: <input file> 1233 e 612 i 43378 f 03 x 22 17 e 9899 a 323e a6 z7 read in the character in position 6, and if that character = e, delete that line from the file. <output file> 43378 f 03 x 22 17 e 9899 ... (4 Replies)
Discussion started by: dabear
4 Replies

10. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies
Login or Register to Ask a Question