The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiple file processing - 1st line only to process - search/match substring toneatlondon Shell Programming and Scripting 2 01-02-2008 09:20 PM
AWK Multi-Line Records Processing RacerX Shell Programming and Scripting 10 10-18-2007 08:46 PM
Appending the line number and a seperator to each line of a file ? pjcwhite Shell Programming and Scripting 4 03-21-2007 01:29 AM
Remove header(first line) and trailer(last line) in ANY given file madhunk Shell Programming and Scripting 2 03-13-2006 03:36 PM
processing line in file fablef00 Shell Programming and Scripting 8 01-23-2006 11:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-19-2008
suma suma is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 1
File processing line by line

Hi,

I am doing file processing line by line. while reading each line at a specified location I am searching for a particular character and then write that line to another file.

Problem is while writing to another file it was supressing the spaces, which I don't want to do.

Any help is appreciable.


the code I used is

processLine(){
line="$@" # get all args
type=`echo $line | cut -c37`
if [ $type = 'A' ] ; then
atlr=`expr $atlr + 1`
echo $line
echo $line >> trana
fi
}

example :
abc1234 XXX40 1100
it was writing to file as
abc1234 XXX40 1100

Thanks in advance
  #2 (permalink)  
Old 07-19-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,759
Code:
atlr=0
while  read record
do
    echo "$record" | cut -c37 | read char
    if [[ "$char" = "A" ]] ; then
         echo "$record"
         atlr=$((atlr + 1 ))
    fi
done < infile > outfile
echo "$atlr lines found"
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




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


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0