| | |
read line is stripping leading spaces
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2007
Posts: 1
Reputation:
Solved Threads: 0
I'm writing a Bash script to read from an input file and write my changes out to an output file. I'm using read and for some reason, it is stripping the leading spaces off of each line. I didn't see any flags in read to turn the stripping off. I'm also runnig this in cygwin, but I don't think that should matter.
The code I am using is something like this.
while read curline;
do
echo "current line " $curline
if [ ! -z "$curline" ]; then
while read outline;
do
echo "$curline" >> $Output_Work
fi
done < $Input_Work
Am I doing something wrong here?
thanks,
Jerome
The code I am using is something like this.
while read curline;
do
echo "current line " $curline
if [ ! -z "$curline" ]; then
while read outline;
do
echo "$curline" >> $Output_Work
fi
done < $Input_Work
Am I doing something wrong here?
thanks,
Jerome
•
•
•
•
[...]
I'm using read and for some reason, it is stripping the leading spaces off of each line.
[...]
Shell Scripting Syntax (Toggle Plain Text)
$ cat infile a a a $ while read;do while> echo "$REPLY" while> done<infile a a a $ while IFS= read;do echo "$REPLY" done<infile a a a $
![]() |
Similar Threads
- read second line or record of csv file (PHP)
- read each line of file (C)
- Read Line from serial port buffer (C)
- file types: eliminating leading white spaces (C)
- Help with error checking code (C++)
Other Threads in the Shell Scripting Forum
- Previous Thread: grep '^[a-zA-Z]'
- Next Thread: awk output separators?
Views: 2012 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting





