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
very first shell program. bebop1111116 Shell Programming and Scripting 3 09-17-2006 09:03 PM
shell program jyotiardeshana Shell Programming and Scripting 4 01-03-2006 06:51 AM
shell program rameshparsa Shell Programming and Scripting 1 11-17-2005 01:18 PM
C shell Program Reza Nazarian Shell Programming and Scripting 2 07-28-2003 02:52 PM
shell program nageshrc UNIX for Advanced & Expert Users 2 11-27-2001 12:32 PM

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 02-19-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
shell program

Iam having file 1 as


wc -l file1 is 8


Code:
QWEERTYUU|7927836357398398398913      yuyuyu                  uyiuyuyuyuy    yuiyuiyuyuyy
FDHGFSHAJK|1476887897877777777771       iopwiiwpoi     e
.
.
.
.
I Need to read the abouve line in file1

so iam using the command as
tail -n 8 file1| read srec
echo "$rec"


now (echo "$rec" )iam getting the out file with the compressed data(without spaces as in file1)

so how i can the output file having same line as in file1
  #2 (permalink)  
Old 02-19-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,728
I seem to get:
1. you want one line
2. you want to specify which line
3. you want the output to be like the file
one way:
Code:
which_line=4
awk -v w=$which_line 'NR==w' file
  #3 (permalink)  
Old 02-21-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
The above file1 in my previous post is only sample record and the file will have records in lacs.
EX

Code:
DWERWDSF6672843829890028   LEEBA@fHEC_com                                                                                      2008-02-030000023.90 0009976 00015.00 2008-03-02LEE,JIN UNICOL                          000000000000012.21 000000000000000.00 CBB0000
so i want to make every line TO HAVE its own spaces. exact space in file1 i need to get in output file.
  #4 (permalink)  
Old 02-21-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
why don't you use something like

while read one_line
do
echo "$one_line"
done

am not understanding what you were trying to achieve with your code
"tail -n 8 file1 | read srec"
  #5 (permalink)  
Old 02-21-2008
nivas
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Post

The code i have mesioned above is sample( one line in large file.). like that lacks of lines in a large file.

Iam using the following function.
Code:
read_file1()
{
  if [ $vcount -ne 0 ]
   then
    tail -n $vcount file1.txt| read vrec
    vacct=`echo $vrec | cut -c 9-24`
    vform=`echo $vrec | cut -c 1-8`
    vcount=$((vcount-1))
  else
    vcount=-1
  fi
}


tHE ABOVE file1, that i have given is not correct. and here is the first line in file1
file1
Code:
ASDWERTS09876500000224208   tlee@URID_com                                                                                      2008
02-030000023.90 0009976 00015.00 2008-03-02LEE,ASKIMODERN TERENCE                          000000000000012.21 000000000000000.00 CBB0

Here iam using read_file1 function to do some calculations in my project.

so iam taking 1st line in vrec variable in the above function.

when writing this vrec to an outputfile. iam getting the file1 1st line having no exact spaces.


pls give suggesions.??
  #6 (permalink)  
Old 02-21-2008
kanu_kanu kanu_kanu is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 15
if i give ,

head -1 file1| read line1
echo "$line1" -- printing with exact spaces.
echo $line1 -- printing without spaces.
  #7 (permalink)  
Old 02-21-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
Quote:
Originally Posted by nivas View Post
tail -n $vcount file1.txt| read vrec
Can you run above command, by substituting value of 'vcount' ?
then do "echo $vrec".

Please paste the o/p here.
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:16 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