HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- restricting characters read
Operating System - HP-UX
1832872
Members
2661
Online
110048
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2001 03:25 AM
05-10-2001 03:25 AM
restricting characters read
Hi
In shell scripting, can we restrict the number of character read ,using the
'read' keyword.
In shell scripting, can we restrict the number of character read ,using the
'read' keyword.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2001 06:10 AM
05-10-2001 06:10 AM
Re: restricting characters read
Praveen,
As far as I know , read does not have any option to count the number of characters. But you can try something like this :-
read DUMMY
LENGTH=`echo ${DUMMY}|wc -m`
if [ "${LENGTH}" -gt 8 ]; then
ANSWER=`echo ${DUMMY} | cut -c 1-8`
else
ANSWER="${DUMMY}"
fi
And use the value of ANSWER to put the 8 character restriction.
Hope this helps.
Praveen
As far as I know , read does not have any option to count the number of characters. But you can try something like this :-
read DUMMY
LENGTH=`echo ${DUMMY}|wc -m`
if [ "${LENGTH}" -gt 8 ]; then
ANSWER=`echo ${DUMMY} | cut -c 1-8`
else
ANSWER="${DUMMY}"
fi
And use the value of ANSWER to put the 8 character restriction.
Hope this helps.
Praveen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2001 06:31 AM
05-10-2001 06:31 AM
Re: restricting characters read
WARNING : it is a very hard response
This output is from a menubased aplication:stty -a < /dev/pts/tb
speed 9600 baud; line = 0;
rows = 25; columns = 132
min = 1; time = 0;
intr = ^U; quit = ^\; erase = ^H; kill = ^C
eof = ^D; eol = ^@; eol2
stop = ^S; start = ^Q; susp
werase
parenb -parodd cs8 -cstopb hupcl -cread -clocal -loblk -crts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -iuclc
-ixon -ixany ixoff -imaxbel -rtsxoff -ctsxon -ienqak
-isig -icanon -iexten -xcase -echo echoe echok -echonl -noflsh
-echoctl -echoprt -echoke -flusho -pendin
opost -olcuc -onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop
____
min=1 ; time = 0
this parameters let keep a only char from keyboard.
See man stty.
AND good luck.
unsupported
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2001 06:48 AM
05-10-2001 06:48 AM
Re: restricting characters read
Praveen:
You can alter the IFS character and thereby redefine the words read by 'read'.
See "read" and "IFS" in 'man sh-posix'.
...JRF...
You can alter the IFS character and thereby redefine the words read by 'read'.
See "read" and "IFS" in 'man sh-posix'.
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP