Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


How to read the nth character from the line.?


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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  
Code:
FIRSTLINE=`head -n 1 $indexFile

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

# 3  
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.
This User Gave Thanks to Scott For This Post:
# 4  
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.
This User Gave Thanks to RudiC For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Read character by character in line in which space is also included
pallvi_mahajan
Hi friend, I have one file , and i want to read that file character by character. I need this script in ksh. while using read option with -n1 am getting error. while read -n1 c read has bad option And if i am using below script, then if in a line has space like this ( Pallvi mahajan)...... Shell Programming and Scripting
10
Shell Programming and Scripting
Search and recursively enter new line after Nth character
Amit786
Hi All, My file is a string of around 50K character. I'm trying to insert new line after every 320 character in my file. I know the command to insert newline, but problem is I'm not able to search 320th position. Please advice.... Shell Programming and Scripting
6
Shell Programming and Scripting
Read a file from the nth line on
nw2unx123
I have a script which reads from a job file and executed the scripts in the job file in sequence. #! /bin/ksh set -x while read line do $line.ksh if # mail the team fi done <"$file" The job file will be like abcd efgh ijkl mnop qrst This is working fine. I need to add...... Shell Programming and Scripting
2
Shell Programming and Scripting
Read file from nth line to specific character
laalesh
Hi, I want to read the file from nth line (where n is an integer) to until I encounter @ char. Can any one please help me how to do this? Thanks.... Shell Programming and Scripting
3
Shell Programming and Scripting
Read last word of nth line
gc_sw
Hi people; i want to read the last word of the 14th line of my file1.txt. Here is the EXACT 14th line of the file. 250 SectorPortnum=3,AuxPortInUngo=2,PortDeviceGroup=1,PortDeviceSet=1,PorDevice=1 20 >>> Set. i have to get the word Set. how can i call it and also how...... Shell Programming and Scripting
3
Shell Programming and Scripting

Featured Tech Videos