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
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
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
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
... 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
... 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
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
${#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
THANK YOU
The administrator has disabled public write access.