Sponsored Content
Top Forums Shell Programming and Scripting Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes Post 302757009 by shravan.300 on Thursday 17th of January 2013 01:50:59 AM
Old 01-17-2013
Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes

hello,

suppose, entered input is of 1-40 bytes, i need it to be converted to 40 bytes exactly.

example: if i have entered my name anywhere between 1-40 i want it to be stored with 40 bytes exactly.

enter your name:
donald duck (this is of 11 bytes)

expected is as below - display 11 bytes entered and rest of the 29 bytes with blank space
donald duck____________________________(i refereed _ to blank space)


my shell script is something like below:
Code:
echo "enter you name"
read name
echo "enter age"
read age
echo $name$age


please help!

Last edited by Franklin52; 01-17-2013 at 03:11 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell script to calc sum of bytes used by files

I'm looking to create a Korn Shell script that, if given a directory as an arg, will calc bytes used by all files in the given directory and display that info. If no command line arg is given the program is to calc and display the bytes used by all the files in the pwd. Example output: ... (3 Replies)
Discussion started by: kecannon
3 Replies

2. Shell Programming and Scripting

Remove first N bytes and last N bytes from a binary file on AIX.

Hi all, Does anybody know or guide me on how to remove the first N bytes and the last N bytes from a binary file? Is there any AWK or SED or any command that I can use to achieve this? Your help is greatly appreciated!! Best Regards, Naveen. (1 Reply)
Discussion started by: naveendronavall
1 Replies

3. Programming

Number of bytes in terminal input queue w/o blocking and consuming?

Hello, everyone. Could someone, please, tell me how to get the number of bytes in the terminal input queue without blocking and without consuming these bytes? I guess it could be called the peek functionality. I've looked at termio tcgetattr() and tcsetattr() functions but could not find... (4 Replies)
Discussion started by: Lucy.Garfeld
4 Replies

4. Shell Programming and Scripting

shell script to convert file_size from bytes to megabytes

Hi All, OS:AIX 64 bits. Requirement is to convert file_size from bytes to megabytes through shell script as below: export DBALIST="xyz@rediffmail.com" ls -ltr abcd.txt > file_size.result export file_size=`awk -F" " '{ print $5 }' file_size.result` if ] then mailx -s "File abcd.txt... (3 Replies)
Discussion started by: a1_win
3 Replies

5. Shell Programming and Scripting

AWK input can not be longer than 3000 bytes

Hi, i have following line in my code. eport.pl < $4 | dos2ux | head -2000 | paste -sd\| - | awk -v S="$1" ' Issue is, i get a message saying "awk:input line | found /file/path cannot be longer than 3000 bytes." "source line number is 3" Can someone help me with this please? (4 Replies)
Discussion started by: usustarr
4 Replies

6. Shell Programming and Scripting

Error PHP Fatal error: Allowed memory size of 67108864 bytes exhausted(tried to allocate 401 bytes)

While running script I am getting an error like Few lines in data are not being processed. After googling it I came to know that adding such line would give some memory to it ini_set("memory_limit","64M"); my input file size is 1 GB. Is that memory limit is based on RAM we have on... (1 Reply)
Discussion started by: elamurugu
1 Replies

7. Shell Programming and Scripting

Shell script to copy a log file if it exceeds 5000000 bytes

Hi, on unix box, under /local/home/userid/logs folder, apps generated the following files sw_warn.log sw_error.log eaijava.log if there any application specific errors, the above file will keep growing. if the file exceed 5000000 bytes, I would like to have a shell script which do... (6 Replies)
Discussion started by: lookinginfo
6 Replies

8. Programming

Copying 1024 bytes data in 3-bytes chunk

Hi, If I want to copy a 1024 byte data stream in to the target location in 3-bytes chunk, I guess I can use the following script. dd bs=1024 count=3 if=/src of=/dest But, I would like to know, how to do it via a C program. I have tried this with memcpy(), that did not help. (3 Replies)
Discussion started by: royalibrahim
3 Replies

9. Shell Programming and Scripting

awk: Input line Cannot be longer than 3,000 bytes.

Guys, I want to get the high CPU utilization from top. I am using below code : top -d2 >> /home/dba_monitoring/host_top_output.txt echo "Script started `date`" > $runlog usage=`grep "^ *$1" /home/dba_monitoring/host_top_output.txt | awk '{print $12}' | sed 's/%//'` And getting below... (7 Replies)
Discussion started by: wahab
7 Replies

10. UNIX for Dummies Questions & Answers

X bytes of 0, Y bytes of random data, Z bytes of 5, T bytes of 1. ??

Hello guys. I really hope someone will help me with this one.. So, I have to write this script who: - creates a file home/student/vmdisk of 10 mb - formats that file to ext3 - mounts that partition to /mnt/partition - creates a file /mnt/partition/data. In this file, there will... (1 Reply)
Discussion started by: razolo13
1 Replies
memory(3C)																memory(3C)

NAME
memory: memccpy(), memchr(), memcmp(), memcpy(), memmove(), memset(), bcmp(), bcopy(), bzero(), ffs() - memory operations SYNOPSIS
Remarks and are provided solely for portability of BSD applications, and are not recommended for new applications where portability is important. For portable applications, use and respectively. has no portable equivalent. DESCRIPTION
These functions operate as efficiently as possible on memory areas (arrays of bytes bounded by a count, not terminated by a null byte). They do not check for the overflow of any receiving memory area. Definitions for all these functions, the type and the constant are provided in the header file. Copy bytes from the object pointed to by s2 into the object pointed to by s1, stopping after the first occurrence of byte c has been copied, or after n bytes have been copied, whichever comes first. If copying takes place between objects that overlap, the behavior is undefined. returns a pointer to the byte after the copy of c in s1, or a NULL pointer if c was not found in the first n bytes of s2. Locate the first occurrence of c (converted to an in the initial n bytes (each interpreted as of the object pointed to by s. returns a pointer to the located byte, or a NULL pointer if the byte does not occur in the object. Compare the first n bytes of the object pointed to by s1 to the first n bytes of the object pointed to by s2. returns an integer greater than, equal to, or less than zero, according to whether the object pointed to by s1 is greater than, equal to, or less than the object pointed to by s2. The sign of a non-zero return value is determined by the sign of the difference between the values of the first pair of bytes (both interpreted as that differ in the objects being compared. Copy n bytes from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined. returns the value of s1. Copy n bytes from the object pointed to by s2 into the object pointed to by s1. Copying takes place as if the n bytes from the object pointed to by s2 are first copied into a temporary array of n bytes that does not overlap the objects pointed to by s1 and s2, and then the n bytes from the temporary array are copied into the object pointed to by s1. returns the value of s1. Copy the value of c (converted to an into each of the first n bytes of the object pointed to by s. returns the value of s. copies n bytes from the area pointed to by s1 to the area pointed to by s2. Compare the first n bytes of the area pointed to by s1 with the area pointed to by s2. returns zero if they are identical; non-zero other- wise. Both areas are assumed to be n bytes in length. Clear n bytes in the area pointed to by s by setting them to zero. Find the first bit set (beginning with the least significant bit) and return the index of that bit. Bits are numbered starting at one. A return value of 0 indicates that i is zero. International Code Set Support These functions support only single-byte byte code sets. WARNINGS
The functions defined in were previously defined in FILES
SEE ALSO
string(3C), thread_safety(5), glossary(9). STANDARDS CONFORMANCE
memory(3C)
All times are GMT -4. The time now is 05:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy