08-11-2006
Issue with reading in records
Hi all,
This is my first post here, so please bear with me!
I have a file coming into a korn shell script, fixed length. Example:
Peter (25 spaces) D (29 spaces) Younan (24 spaces)
Jim (27 spaces) (30 spaces) Shue (26 spaces)
I am performing a while loop to read in the file and assign each record to a variable called THELINE. I then try to assign the various columns by doing an echo and piping into cut. Example:
FIELD1=`echo $THELINE | cut -c1-15` # FIRST NAME
FIELD2=`echo $THELINE | cut -c16-45` # MIDDLE NAME
etc
What's happening is echo is compressing the "extra" white spaces between the name fields, so FIELD1 looks like this:
Peter D Younan
instead of this (desired):
Peter
Any ideas on how I can get around this issue?
Thanks!
Pete
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to read all numeric records that start with the line id and write them to a new file.
input:
====
blah blah
blah blah
id
10 11 12
13 14 15
blah blah
blah blah
id
16 17 18
19 20 21
output:
10 11 12
13 14 15 (10 Replies)
Discussion started by: andy2000
10 Replies
2. Shell Programming and Scripting
Hi All,
I have two files say file1 and file2.
I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions .
Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies
3. UNIX for Advanced & Expert Users
HI All
I have csv file containing the data like this
Electrical Equipment,ElecEquip
"Engineering, Machinery & Equipment",Engineerin
Entertainment & Broadcasting,Entertain
The first and third record are fine,The issue with second records as it has comma enclosed with in inverted... (1 Reply)
Discussion started by: mohdtausifsh
1 Replies
4. UNIX for Dummies Questions & Answers
Hi
Am having issue on appending time stamp
I know the exact file names in the directory like
a.dat
b.dat
c.dat
e.dat
f.dat
I want to read all these file names and append the timestamp to each files like
a.dat.20090604,b.dat.20090604 and move to the different directory.
... (3 Replies)
Discussion started by: bobprabhu
3 Replies
5. UNIX for Dummies Questions & Answers
Hi everyone.
I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this:
ID: 20
Name: X
Age: 19
ID: 21
Name: Z
ID: 22
Email: xxx@yahoo.com
Name: Y
Age: 19
I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies
6. Shell Programming and Scripting
Hi
Need urgent help (2 Replies)
Discussion started by: premp26
2 Replies
7. Shell Programming and Scripting
Hi Freinds ,
I have 2 files .
File 1
|nag|HYd|1|Che
|esw|Gun|2|hyd
|pra|bhe|3|hyd
|omu|hei|4|bnsj
|uer|oeri|5|uery
File 2
|nag|HYd|1|Che
|esw|Gun|2|hyd
|uer|oi|3|uery
output : (9 Replies)
Discussion started by: i150371485
9 Replies
8. Shell Programming and Scripting
Hi Friends,
I am trying to scan line by line using awk and pull the values and pass it in variables and then will use the variables but doesn't work.
Please see below for details.
#more dbtest.sh
----------------------------------
#!/bin/bash
. $HOME/.bash_profile
while read line
do... (6 Replies)
Discussion started by: narunice
6 Replies
9. Shell Programming and Scripting
Hello
I'm writing a handler for ffmpeg, and having troubles to catch some exceptions that may occour with certain files.
In order to parse for video & subtitle maps, i've had to make the raw data easier to handle, until now this worked well, but basicly i've just been lucky...
The input... (1 Reply)
Discussion started by: sea
1 Replies
10. UNIX for Beginners Questions & Answers
I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected.
LOAD DATA
infile ' ' #specifies the name of a datafile containing data that you want to load
BADFILE ' ' #specifies the name of... (1 Reply)
Discussion started by: raka123
1 Replies