👤
Home Man
Search
Today's Posts
Register

Forum members, please contact us here (not via email or PM).
Bug reports and minor feature requests should be posted here.

How to read the nth character from the line.?

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
Old 12-19-2017
How to read the nth character from the line.?

I have Index Line and I tried to get the 9th character from the file and to check the character is "|" or not.
Shell Scripting.


Sample Index file.

Code:
"91799489|K8E|188.004.A.917994892.1099R.c.01.pdf|2013|10/15/2014|002|B|C|C"
"917994898|K8E|188.004.A.917994892.1099R.c.01.pdf|2013|10/15/2014|002|B|C|C"

# 2  
Old 12-19-2017
Code:
FIRSTLINE=`head -n 1 $indexFile

   while read -r line
   do
   id = cut -c 9 $FIRSTLINE
   echo $id 
done < "$indexFile"

# 3  
Old 12-19-2017
For the last time, please do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
The Following User Says Thank You to Scott For This Useful Post:
Neo (12-24-2017)
# 4  
Old 12-19-2017
Welcome to the forum.

You've been told twice already to
- follow the rules.
- post in an adequate forum - certainly not "Post Here to Contact Site Administrators and Moderators".
- post homework ONLY in https://www.unix.com/homework-coursework-questions/ and fill in the form completely.
- use code tags

Sorry, this thread is closed again.
The Following User Says Thank You to RudiC For This Useful Post:
Neo (12-24-2017)
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replace nth to nth character? stinkefisch Shell Programming and Scripting 2 07-13-2015 02:26 AM
Read character by character in line in which space is also included pallvi_mahajan Shell Programming and Scripting 10 10-28-2014 01:21 PM
Search and recursively enter new line after Nth character Amit786 Shell Programming and Scripting 6 02-18-2014 02:02 PM
Read a file from the nth line on nw2unx123 Shell Programming and Scripting 2 03-20-2013 03:25 PM
Calculating average for every Nth line in the Nth column ncwxpanther Shell Programming and Scripting 3 04-12-2012 08:56 AM
Read file from nth line to specific character laalesh Shell Programming and Scripting 3 03-22-2012 08:58 AM
How to read one character form each line of the file? arsii Shell Programming and Scripting 0 12-11-2010 09:07 AM
Read last word of nth line gc_sw Shell Programming and Scripting 3 11-02-2010 07:48 AM
Read line based on character, naree Shell Programming and Scripting 3 06-14-2010 06:58 AM
Read First Character of Each Line in File azelinsk Shell Programming and Scripting 7 07-11-2007 08:15 PM


All times are GMT -4. The time now is 09:15 PM.

Unix & Linux Forums Content CopyrightŠ1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?