How can I write into a particular line of a file in a bash script? -


i want write data taken file last line (not in new line) of file. using following script.

#!/bin/bash echo "write start , end file number:" read sta end  echo "$sta" "$end"  (( c="$sta"; c<="$end"; c++ ))    cp analyzeclusterparameterfile analyzeclusterparameterfile$c    awk '{if (nr== '$c' -10){print $1 " " $2 " " $3}}' center.dat >>  analyzeclusterparameterfile$c   done 

but (analyzeclusterparameterfile$c file) going new line this

rinner = 0.1 ! in mpc

router = 5 ! in mpc

numberofpoints = 50 ! default 16

virialdensity = 200 ! default 200

centerlistname =

5.044627347e-01 5.008533222e-01 5.043365095e-01

what want(analyzeclusterparameterfile$c file)

rinner = 0.1 ! in mpc

router = 5 ! in mpc

numberofpoints = 50 ! default 16

virialdensity = 200 ! default 200

centerlistname = 5.044627347e-01 5.008533222e-01 5.043365095e-01

this due newline character @ end of analyzeclusterparameterfile. can remove replacing cp command with:

head -c -1 analyzeclusterparameterfile > analyzeclusterparameterfile$c 

beware, kill trailing character, not newlines!


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -