Character first registration


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Character first registration
# 1  
Old 12-28-2015
Character first registration

friends
I have the following code that works perfect

Code:
while read linea
     do


       largo=${#linea}
       echo "largo es///////////: $largo "


      if [ $largo -ne 171 ]
       then
         echo "Longitud De Registro Invalida"
         echo " $linea > ERROR DE LONGITUD"  >>  $PATH_DAT/$ArchSalida
       fi
     done <  ${PATH_DAT}/$ArchPro #while read linea

before this condition

Code:
if [ $largo -ne 171 ]
       then
         echo "Longitud De Registro Invalida"
         echo " $linea > ERROR DE LONGITUD"  >>  $PATH_DAT/$ArchSalida
       fi

I need to ask for the first 2 characters in the record
# 2  
Old 12-28-2015
An old school way:

Code:
expr "${linea}" : '\(..\)'

# 3  
Old 12-28-2015
What shell are you using?
What operating system are you using?

With a 1993 or later ksh (called ksh93 on some systems) or with a recent bash, you can use a substring parameter expansion:
Code:
${linea:0:2}

to get the 1st two characters. (The general format is:
Code:
${variable:offset:length}

where the 1st character of the string has offset zero (not one).)
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Registration request.

Hi, i got several questions regarding Solaris 10 configuration which i would like to ask here. Unfortunately Russia is blacklisted so I cannot register the normal way. My IP is: 5.19.nnn.nnn email: <removed> Thank you. (5 Replies)
Discussion started by: nongrato
5 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Registration proposal

Hello. I've been reading the feed via twitter for a long time, but though i'm willing to help, i can't post and register (russia's banned). IP is dynamic, it's (<ip address>) for now. DevOps, RH, python and unix shell scripting. (5 Replies)
Discussion started by: spider_fingers
5 Replies

3. Solaris

Solaris 10 without registration

Hello people, I'm a private one and have no a support contract with Oracle, Sun Microsystems. And I want to test the Solaris10 U10 and play with no limit. I can use the Solaris 10 U10 without registration. Or must I obtain a contract to Sun for this test Thanks for the answer greeting ... (4 Replies)
Discussion started by: alkhatw
4 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Problem with registration

When I'm trying to register it says that my e-mail adress )is banned by administrator. Why? Thanks PS The same problem occurs with other 2 adresses I have (1 Reply)
Discussion started by: Mihail
1 Replies

5. Forum Support Area for Unregistered Users & Account Problems

Need help with forum registration

i can not register, please help me (1 Reply)
Discussion started by: friender@mail
1 Replies

6. Post Here to Contact Site Administrators and Moderators

How to delete registration please?

How do I delete my registration please? (1 Reply)
Discussion started by: amaitland
1 Replies

7. IP Networking

DNS registration

How can I set up a DNS to host several registered domains on my own computer or where can I find information related with this? Rigo.:confused: (3 Replies)
Discussion started by: rigo
3 Replies
Login or Register to Ask a Question