Issues with cut


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues with cut
# 1  
Old 09-08-2005
Issues with cut

We are running on a Sun cluster using ksh.

We have a script that has been running for about six months with no issues. The script has not been modified and our results are now coming out diffrent.


<BEGIN>
cat $exfile | while read line
do


revnpa=`echo $line |cut -c 1-10 | sed '/\n/!G;s/\(.\)\(.
*\n\)/&\2\1/;//D;s/.//'`
wtn=`echo $line |cut -c 1-10`
name=`echo $line | cut -c 11-25`
orig=999
wkfile=$workdir/OUT
insert=I

echo $revnpa$insert$wtn$name$orig >> OUT

<END>

The $exfile is a file that 26 bytes including /n
The name variable for whatever reason is deleting trailing white spaces rather than grabbing the full 15 bytes. We have verified using od that the spaces due in fact exist in the input file but are dropped during the variable assignment. Command line works fine but not in script. Shell is defined on first line

Thanks for any assistance
# 2  
Old 09-08-2005
If that code really used to work either line had a typeset or there was a non-default IFS in force. My guess is that IFS changed somehow.

Code:
$ echo "a          " | read avar ; echo ${#avar}
1
$ IFS=""
$ echo "a          " | read avar ; echo ${#avar}
11
$

Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. Shell Programming and Scripting

Cut command on RHEL 6.8 compatibility issues

We have a lot of scripts using cut as : cut -c 0-8 --works for cut (GNU coreutils) 5.97, but does not work for cut (GNU coreutils) 8.4. Gives error - cut: fields and positions are numbered from 1 Try `cut --help' for more information. The position needs to start with 1 for later... (6 Replies)
Discussion started by: Vikram Jain
6 Replies

3. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

4. Homework & Coursework Questions

sed & cut command issues

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: After using the egrep command to pull certain lines from the asg5f1 (creating the asg5f1c file), I am required... (1 Reply)
Discussion started by: robrom78
1 Replies

5. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

6. UNIX for Dummies Questions & Answers

having issues in using Cut Command

Hi, I would like to ask for your help with my problem, im writing a unix script to remove characters before the symbol "/", but the one being removed are characters after the symbol. Ive searched over the internet and found no answer.. hope you can help me with this. sample: text... (2 Replies)
Discussion started by: paoie
2 Replies
Login or Register to Ask a Question