My Profile

Keep Up to Date:
Blog RSS
Blog
Forum RSS
Forum
Post New Topic Post Reply
Posted 3 Weeks, 1 Day ago
ppreddy
Senior Boarder
Posts: 79
graphgraph
User Offline
 
hi cat a.txt >> b.txt will append a.txt to the end of b.txt. But how can i replace a.txt to b.txt start at the beginning?

for example: if a.txt contain 'abc' and b.txt contain '123456' i want 'abc456' in b.txt

thanks from Peter ( This e-mail address is being protected from spam bots, you need JavaScript enabled to view it )
The administrator has disabled public write access.
Posted 3 Weeks ago
Arligoth
Senior Boarder
Posts: 69
graphgraph
User Offline
 
I don't think you can do this from the shell. You can do it from (at least) C or Perl, though:
The administrator has disabled public write access.
Posted 3 Weeks ago
Steven_Osteon
Senior Boarder
Posts: 62
graphgraph
User Offline
 
fernando@linx4 tmp $ cat a abc fernando@linx4 tmp $ cat b 123456 fernando@linx4 tmp $ dd if=a of=b bs=1 count=3 conv=notrunc 3+0 records in 3+0 records out fernando@linx4 tmp $ cat b
The administrator has disabled public write access.
Posted 3 Weeks ago
mystic_moose
Senior Boarder
Posts: 66
graphgraph
User Offline
 
i dunno about dd, looks like magic to me. most folks will use awk or sed for the stated purpose. try the man pages.
The administrator has disabled public write access.
Posted 2 Weeks, 6 Days ago
ppreddy
Senior Boarder
Posts: 79
graphgraph
User Offline
 
... that's the beauty of *nix ... there are multiple ways to skin a 'cat' (pun intended
The administrator has disabled public write access.
Posted 2 Weeks, 6 Days ago
Arligoth
Senior Boarder
Posts: 69
graphgraph
User Offline
 
... hehehehehehhee. i can NEVER figure this out. every time i see the command 'wc', i think of the expression 'water closet'
The administrator has disabled public write access.
Posted 2 Weeks, 6 Days ago
Bhaumik Shukla
Expert Boarder
Posts: 81
graphgraph
User Offline
 
thanks foor all the reply. When i echo '#f1', nothing come out. What does the #f1 mean?

thank you from Peter ( This e-mail address is being protected from spam bots, you need JavaScript enabled to view it )
The administrator has disabled public write access.
Posted 2 Weeks, 5 Days ago
Bhah_Humbug
Senior Boarder
Posts: 54
graphgraph
User Offline
 
${#f1} is the length of the variable f1 ${f2} is the value of the variable f2, starting from position x

So,

${f2:${#f1}} is the value of the variable f2, starting from the position of the last character in f1.
The administrator has disabled public write access.
Posted 2 Weeks, 5 Days ago
ejtaal
Expert Boarder
Posts: 80
graphgraph
User Offline
 
THANK YOU
The administrator has disabled public write access.
 
Copyright © 2006 - Dec 2008 My Linux Gang