hardlink/softlink multiple file to one file
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I have many files in a folder. I want to concatenate all these files to a single file. For example cat * > final_file; But this will increase disk space and also will consume time. Is there is a way where I can hardlink/softlink all the files to final_file? For example ln * final_file.
symlink cat hard-link
add a comment |Â
up vote
3
down vote
favorite
I have many files in a folder. I want to concatenate all these files to a single file. For example cat * > final_file; But this will increase disk space and also will consume time. Is there is a way where I can hardlink/softlink all the files to final_file? For example ln * final_file.
symlink cat hard-link
1
Related: Virtual file made out of smaller ones (for mac-like sparse bundle solution) and How to split a ddrescue disk image and how to use it again?
â Stéphane Chazelas
Jul 31 '13 at 20:33
You could use FUSE for this task. I've created a simple example on how to accomplish this: cat-fuse.
â Jakub Nowak
Aug 19 at 19:35
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have many files in a folder. I want to concatenate all these files to a single file. For example cat * > final_file; But this will increase disk space and also will consume time. Is there is a way where I can hardlink/softlink all the files to final_file? For example ln * final_file.
symlink cat hard-link
I have many files in a folder. I want to concatenate all these files to a single file. For example cat * > final_file; But this will increase disk space and also will consume time. Is there is a way where I can hardlink/softlink all the files to final_file? For example ln * final_file.
symlink cat hard-link
symlink cat hard-link
edited Jul 31 '13 at 22:55
Gilles
510k12010081537
510k12010081537
asked Jul 31 '13 at 19:59
quartz
11814
11814
1
Related: Virtual file made out of smaller ones (for mac-like sparse bundle solution) and How to split a ddrescue disk image and how to use it again?
â Stéphane Chazelas
Jul 31 '13 at 20:33
You could use FUSE for this task. I've created a simple example on how to accomplish this: cat-fuse.
â Jakub Nowak
Aug 19 at 19:35
add a comment |Â
1
Related: Virtual file made out of smaller ones (for mac-like sparse bundle solution) and How to split a ddrescue disk image and how to use it again?
â Stéphane Chazelas
Jul 31 '13 at 20:33
You could use FUSE for this task. I've created a simple example on how to accomplish this: cat-fuse.
â Jakub Nowak
Aug 19 at 19:35
1
1
Related: Virtual file made out of smaller ones (for mac-like sparse bundle solution) and How to split a ddrescue disk image and how to use it again?
â Stéphane Chazelas
Jul 31 '13 at 20:33
Related: Virtual file made out of smaller ones (for mac-like sparse bundle solution) and How to split a ddrescue disk image and how to use it again?
â Stéphane Chazelas
Jul 31 '13 at 20:33
You could use FUSE for this task. I've created a simple example on how to accomplish this: cat-fuse.
â Jakub Nowak
Aug 19 at 19:35
You could use FUSE for this task. I've created a simple example on how to accomplish this: cat-fuse.
â Jakub Nowak
Aug 19 at 19:35
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
5
down vote
accepted
With links, I'm afraid, this will not be possible. However, you could use a
named pipe. Example:
# create some dummy files
echo alpha >a
echo beta >b
echo gamma >c
# create named pipe
mkfifo allfiles
# concatenate files into pipe
cat a b c >allfiles
The last call will block until some process reads from the pipe and then exit. For a continuous operation one can use a loop, which waits for a process to read and starts over again.
while true; do
cat a b c >allfiles
done
Wouldn'tcat
block until a process starts reading from the named pipe?
â Joseph R.
Jul 31 '13 at 20:10
@JosephR. Yes, it would. Append&
if that's not desired.
â Marco
Jul 31 '13 at 20:14
1
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content viaallfiles
?
â Joseph R.
Jul 31 '13 at 20:15
Indeed. Usewhile true; do cat a b c >allfiles; done
if that's not desired.
â Marco
Jul 31 '13 at 20:18
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
add a comment |Â
up vote
2
down vote
This is not possible.
N files mean N inodes. Hard links, by definition, are simply different names for the same inode. Symlinks are files that point to a certain inode (their target). Either way, soft or hard, the link can refer to a single inode.
add a comment |Â
up vote
2
down vote
In a straight way, no ...
You cannot hard/soft link to a single file. links are nothing more and nothing less than pointer from one file to another.
Now if you are worried about space and want to release the space you can do the following:
for i in *
do
cat < "$i" >> destination_file &&
rm -f -- "$i"
done
Basically, it will append the output to destination_file and remove the file afterwards. Also I'm assuming you don't need the original files.
1
Why do you parsels
? Just usefor i in *
. And why the loop in the first place? Just docat * >> destination
.
â Marco
Jul 31 '13 at 20:10
Why not quote the variable ("$i"
) to allow for spaces in the file name?
â Joseph R.
Jul 31 '13 at 20:13
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
1
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
1
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just usecat * >dest
followed byrm !(dest)
(bash) orrm ^dest
(zsh).
â Marco
Jul 31 '13 at 20:41
 |Â
show 6 more comments
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
With links, I'm afraid, this will not be possible. However, you could use a
named pipe. Example:
# create some dummy files
echo alpha >a
echo beta >b
echo gamma >c
# create named pipe
mkfifo allfiles
# concatenate files into pipe
cat a b c >allfiles
The last call will block until some process reads from the pipe and then exit. For a continuous operation one can use a loop, which waits for a process to read and starts over again.
while true; do
cat a b c >allfiles
done
Wouldn'tcat
block until a process starts reading from the named pipe?
â Joseph R.
Jul 31 '13 at 20:10
@JosephR. Yes, it would. Append&
if that's not desired.
â Marco
Jul 31 '13 at 20:14
1
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content viaallfiles
?
â Joseph R.
Jul 31 '13 at 20:15
Indeed. Usewhile true; do cat a b c >allfiles; done
if that's not desired.
â Marco
Jul 31 '13 at 20:18
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
add a comment |Â
up vote
5
down vote
accepted
With links, I'm afraid, this will not be possible. However, you could use a
named pipe. Example:
# create some dummy files
echo alpha >a
echo beta >b
echo gamma >c
# create named pipe
mkfifo allfiles
# concatenate files into pipe
cat a b c >allfiles
The last call will block until some process reads from the pipe and then exit. For a continuous operation one can use a loop, which waits for a process to read and starts over again.
while true; do
cat a b c >allfiles
done
Wouldn'tcat
block until a process starts reading from the named pipe?
â Joseph R.
Jul 31 '13 at 20:10
@JosephR. Yes, it would. Append&
if that's not desired.
â Marco
Jul 31 '13 at 20:14
1
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content viaallfiles
?
â Joseph R.
Jul 31 '13 at 20:15
Indeed. Usewhile true; do cat a b c >allfiles; done
if that's not desired.
â Marco
Jul 31 '13 at 20:18
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
With links, I'm afraid, this will not be possible. However, you could use a
named pipe. Example:
# create some dummy files
echo alpha >a
echo beta >b
echo gamma >c
# create named pipe
mkfifo allfiles
# concatenate files into pipe
cat a b c >allfiles
The last call will block until some process reads from the pipe and then exit. For a continuous operation one can use a loop, which waits for a process to read and starts over again.
while true; do
cat a b c >allfiles
done
With links, I'm afraid, this will not be possible. However, you could use a
named pipe. Example:
# create some dummy files
echo alpha >a
echo beta >b
echo gamma >c
# create named pipe
mkfifo allfiles
# concatenate files into pipe
cat a b c >allfiles
The last call will block until some process reads from the pipe and then exit. For a continuous operation one can use a loop, which waits for a process to read and starts over again.
while true; do
cat a b c >allfiles
done
edited Jul 31 '13 at 20:21
answered Jul 31 '13 at 20:09
Marco
24.4k580113
24.4k580113
Wouldn'tcat
block until a process starts reading from the named pipe?
â Joseph R.
Jul 31 '13 at 20:10
@JosephR. Yes, it would. Append&
if that's not desired.
â Marco
Jul 31 '13 at 20:14
1
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content viaallfiles
?
â Joseph R.
Jul 31 '13 at 20:15
Indeed. Usewhile true; do cat a b c >allfiles; done
if that's not desired.
â Marco
Jul 31 '13 at 20:18
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
add a comment |Â
Wouldn'tcat
block until a process starts reading from the named pipe?
â Joseph R.
Jul 31 '13 at 20:10
@JosephR. Yes, it would. Append&
if that's not desired.
â Marco
Jul 31 '13 at 20:14
1
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content viaallfiles
?
â Joseph R.
Jul 31 '13 at 20:15
Indeed. Usewhile true; do cat a b c >allfiles; done
if that's not desired.
â Marco
Jul 31 '13 at 20:18
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
Wouldn't
cat
block until a process starts reading from the named pipe?â Joseph R.
Jul 31 '13 at 20:10
Wouldn't
cat
block until a process starts reading from the named pipe?â Joseph R.
Jul 31 '13 at 20:10
@JosephR. Yes, it would. Append
&
if that's not desired.â Marco
Jul 31 '13 at 20:14
@JosephR. Yes, it would. Append
&
if that's not desired.â Marco
Jul 31 '13 at 20:14
1
1
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content via
allfiles
?â Joseph R.
Jul 31 '13 at 20:15
Great. But wouldn't the OP need to repeat these steps every time he/she wants to access the full content via
allfiles
?â Joseph R.
Jul 31 '13 at 20:15
Indeed. Use
while true; do cat a b c >allfiles; done
if that's not desired.â Marco
Jul 31 '13 at 20:18
Indeed. Use
while true; do cat a b c >allfiles; done
if that's not desired.â Marco
Jul 31 '13 at 20:18
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
Thanks for bearing with me (I'm still grappling with the fifo concept). I think your notes should be added to the answer as the OP might not be aware of that.
â Joseph R.
Jul 31 '13 at 20:19
add a comment |Â
up vote
2
down vote
This is not possible.
N files mean N inodes. Hard links, by definition, are simply different names for the same inode. Symlinks are files that point to a certain inode (their target). Either way, soft or hard, the link can refer to a single inode.
add a comment |Â
up vote
2
down vote
This is not possible.
N files mean N inodes. Hard links, by definition, are simply different names for the same inode. Symlinks are files that point to a certain inode (their target). Either way, soft or hard, the link can refer to a single inode.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
This is not possible.
N files mean N inodes. Hard links, by definition, are simply different names for the same inode. Symlinks are files that point to a certain inode (their target). Either way, soft or hard, the link can refer to a single inode.
This is not possible.
N files mean N inodes. Hard links, by definition, are simply different names for the same inode. Symlinks are files that point to a certain inode (their target). Either way, soft or hard, the link can refer to a single inode.
answered Jul 31 '13 at 20:05
Joseph R.
27.2k368111
27.2k368111
add a comment |Â
add a comment |Â
up vote
2
down vote
In a straight way, no ...
You cannot hard/soft link to a single file. links are nothing more and nothing less than pointer from one file to another.
Now if you are worried about space and want to release the space you can do the following:
for i in *
do
cat < "$i" >> destination_file &&
rm -f -- "$i"
done
Basically, it will append the output to destination_file and remove the file afterwards. Also I'm assuming you don't need the original files.
1
Why do you parsels
? Just usefor i in *
. And why the loop in the first place? Just docat * >> destination
.
â Marco
Jul 31 '13 at 20:10
Why not quote the variable ("$i"
) to allow for spaces in the file name?
â Joseph R.
Jul 31 '13 at 20:13
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
1
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
1
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just usecat * >dest
followed byrm !(dest)
(bash) orrm ^dest
(zsh).
â Marco
Jul 31 '13 at 20:41
 |Â
show 6 more comments
up vote
2
down vote
In a straight way, no ...
You cannot hard/soft link to a single file. links are nothing more and nothing less than pointer from one file to another.
Now if you are worried about space and want to release the space you can do the following:
for i in *
do
cat < "$i" >> destination_file &&
rm -f -- "$i"
done
Basically, it will append the output to destination_file and remove the file afterwards. Also I'm assuming you don't need the original files.
1
Why do you parsels
? Just usefor i in *
. And why the loop in the first place? Just docat * >> destination
.
â Marco
Jul 31 '13 at 20:10
Why not quote the variable ("$i"
) to allow for spaces in the file name?
â Joseph R.
Jul 31 '13 at 20:13
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
1
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
1
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just usecat * >dest
followed byrm !(dest)
(bash) orrm ^dest
(zsh).
â Marco
Jul 31 '13 at 20:41
 |Â
show 6 more comments
up vote
2
down vote
up vote
2
down vote
In a straight way, no ...
You cannot hard/soft link to a single file. links are nothing more and nothing less than pointer from one file to another.
Now if you are worried about space and want to release the space you can do the following:
for i in *
do
cat < "$i" >> destination_file &&
rm -f -- "$i"
done
Basically, it will append the output to destination_file and remove the file afterwards. Also I'm assuming you don't need the original files.
In a straight way, no ...
You cannot hard/soft link to a single file. links are nothing more and nothing less than pointer from one file to another.
Now if you are worried about space and want to release the space you can do the following:
for i in *
do
cat < "$i" >> destination_file &&
rm -f -- "$i"
done
Basically, it will append the output to destination_file and remove the file afterwards. Also I'm assuming you don't need the original files.
edited Jul 31 '13 at 20:42
Stéphane Chazelas
285k53525864
285k53525864
answered Jul 31 '13 at 20:07
BitsOfNix
4,03121531
4,03121531
1
Why do you parsels
? Just usefor i in *
. And why the loop in the first place? Just docat * >> destination
.
â Marco
Jul 31 '13 at 20:10
Why not quote the variable ("$i"
) to allow for spaces in the file name?
â Joseph R.
Jul 31 '13 at 20:13
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
1
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
1
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just usecat * >dest
followed byrm !(dest)
(bash) orrm ^dest
(zsh).
â Marco
Jul 31 '13 at 20:41
 |Â
show 6 more comments
1
Why do you parsels
? Just usefor i in *
. And why the loop in the first place? Just docat * >> destination
.
â Marco
Jul 31 '13 at 20:10
Why not quote the variable ("$i"
) to allow for spaces in the file name?
â Joseph R.
Jul 31 '13 at 20:13
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
1
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
1
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just usecat * >dest
followed byrm !(dest)
(bash) orrm ^dest
(zsh).
â Marco
Jul 31 '13 at 20:41
1
1
Why do you parse
ls
? Just use for i in *
. And why the loop in the first place? Just do cat * >> destination
.â Marco
Jul 31 '13 at 20:10
Why do you parse
ls
? Just use for i in *
. And why the loop in the first place? Just do cat * >> destination
.â Marco
Jul 31 '13 at 20:10
Why not quote the variable (
"$i"
) to allow for spaces in the file name?â Joseph R.
Jul 31 '13 at 20:13
Why not quote the variable (
"$i"
) to allow for spaces in the file name?â Joseph R.
Jul 31 '13 at 20:13
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
@JosephR. That doesn't help. If you have special characters it'll break.
â Marco
Jul 31 '13 at 20:16
1
1
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
@Marco in the OP he's worried about space. otherwise cat * >> destination was more than enough ... hence the loop to cat and remove the file.
â BitsOfNix
Jul 31 '13 at 20:36
1
1
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just use
cat * >dest
followed by rm !(dest)
(bash) or rm ^dest
(zsh).â Marco
Jul 31 '13 at 20:41
@AlexandreAlves My point is: i) This loop is terrible. ii) It it totally unnecessary. Just use
cat * >dest
followed by rm !(dest)
(bash) or rm ^dest
(zsh).â Marco
Jul 31 '13 at 20:41
 |Â
show 6 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f85097%2fhardlink-softlink-multiple-file-to-one-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Related: Virtual file made out of smaller ones (for mac-like sparse bundle solution) and How to split a ddrescue disk image and how to use it again?
â Stéphane Chazelas
Jul 31 '13 at 20:33
You could use FUSE for this task. I've created a simple example on how to accomplish this: cat-fuse.
â Jakub Nowak
Aug 19 at 19:35