shell program

Iam having file 1 as

wc -l file1 is 8

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

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:
which_line=4
awk -v w=$which_line 'NR==w' file

The above file1 in my previous post is only sample record and the file will have records in lacs.
EX

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.

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"

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.

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

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.??

if i give ,

head -1 file1| read line1
echo "$line1" -- printing with exact spaces.
echo $line1 -- printing without spaces.

Can you run above command, by substituting value of 'vcount' ?
then do "echo $vrec".

Please paste the o/p here.

Yes....I have executed the command which Kanu kanu have given..

It it corrcetly with spaces.

Yes....I have executed the command which Kanu kanu have given..

It it corrcetly with spaces. Thank you very much