Jump to content

How do I Symlink files to combine them like so?

Poet129
Go to solution Solved by Sauron,

No, links are a file system feature and are independent of a file's contents. If you want to concatenate files like that you can make a script that checks for changes on those files and updates another file that contains the contents of both - then have that script run periodically as a service either through systemd or something else like cron.

Is it possible to link to another files contents within a different file? Like this...

 

Text1.txt

Contains

"Example Words"

 

Text2.txt

Contains

"Text2 Example"

 

Text.txt

shows this if a program reads it, and if edits are made it goes to the file the text belongs to.

"Example Words

Text2 Example"

Link to comment
Share on other sites

Link to post
Share on other sites

I could be wrong,

 

But I always understood symlink and hardlinks as basically shortcuts.

 

eg:

if you have file.txt on Drive C but an APP requires it to be on drive D use SYMlink to make a linked copy of the file

 

I use symlinks for the apple backup folder on C drive to stop waste space of SSDs for customers..

 

Hardlinks I think are simnilar but to stay on Drive C.. just duplicate the item without using more disk space... as example

Few Systems,

Lenovo Flex 14, Ryzen 3500U, 20GB Ram, 1TB Samsung Evo, 512 GB MicroSD

 

METABOX APLHA-X 17.3" Gaming Laptop, i7 8750H, 24GB DDR4 2400MHz, GTX1060 6GB, 2TB Seagate HDD, 512GB SSD Intel 660p, 17.3" Screen

 

2X COOL CRAZY A$$ WALL COMPUTERS DIY.      Link to my website / pictures of my Wall PC's

 

1st Wall PC, Ryzen 3900X, Gigabyte Gaming 5 X370 32GB Corsair Dom 3200Mhz, 256GB SM951 Samsung SSD, 7x 5TB HDD's, Zotac AMP Extreme GTX 1070, EVGA P2 850Watt PSU

 

2nd Wall PC, i7 8700K @ 4.8GHz, Gigabyte Gaming 7 Z370 16GB Viper 3733Mhz DDR4, 256 Samsung PRO SSD, SM951 Samsung SSD, 1x 4TB HDD, Zotac AMP Extreme GTX 1080ti, EVGA P2 750Watt PSU

 

Media Centre PC's AMD R5 1600, 8GB, just a tv system ITX Based

 

Workstation, Portable disk cloner DIY Construction with screen in chassis. Ryzen 2200G 8GB DDR4

 

Blender RENDERBOX, Ryzen Threadripper 2970WX, 32GB DDR4 2933 HyperX, 4X 1070 GTX, Seasonic 1000Watt Psu

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, toxsickcity said:

I could be wrong,

 

But I always understood symlink and hardlinks as basically shortcuts.

 

eg:

if you have file.txt on Drive C but an APP requires it to be on drive D use SYMlink to make a linked copy of the file

 

I use symlinks for the apple backup folder on C drive to stop waste space of SSDs for customers..

 

Hardlinks I think are simnilar but to stay on Drive C.. just duplicate the item without using more disk space... as example

Yes but I'n looking to do it on a file content basis like explained below.

 

5 minutes ago, Poet129 said:

Is it possible to link to another files contents within a different file? Like this...

 

Text1.txt

Contains

"Example Words"

 

Text2.txt

Contains

"Text2 Example"

 

Text.txt

shows this if a program reads it, and if edits are made it goes to the file the text belongs to.

"Example Words

Text2 Example"

 

Link to comment
Share on other sites

Link to post
Share on other sites

So you want a text file where it's contents are actually two different separate text files?

 

That's not a symlink - in fact, I don't think there's a way to do that with text files.

 

You can do that with certain other file types, like HTML, where you can have nested files.

For Sale: Meraki Bundle

 

iPhone Xr 128 GB Product Red - HP Spectre x360 13" (i5 - 8 GB RAM - 256 GB SSD) - HP ZBook 15v G5 15" (i7-8850H - 16 GB RAM - 512 GB SSD - NVIDIA Quadro P600)

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, dalekphalm said:

So you want a text file where it's contents are actually two different separate text files?

 

That's not a symlink - in fact, I don't think there's a way to do that with text files.

 

You can do that with certain other file types, like HTML, where you can have nested files.

This what I'm looking to do. I wasn't sure if there was a way but I thought someone might know.

Link to comment
Share on other sites

Link to post
Share on other sites

No, links are a file system feature and are independent of a file's contents. If you want to concatenate files like that you can make a script that checks for changes on those files and updates another file that contains the contents of both - then have that script run periodically as a service either through systemd or something else like cron.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Not possible, as @Sauron said, unless you come up with your own file format and write an editor that is capable of editing such files. It would not longer be plain text file though (it could still contain text, but it would need some form of meta-language to define links).

 

However, your idea has one pitfall. Let's say your files look like this:

Text-A.txt

Content-A

Text-B.txt

Content-B

 

If you open your "combined" file, you expect to see this:

Text.txt

Content-A
Content-B

 

What happens if you edit the file to look like this:

Content-A
Something new
Content-B

 

Should "Something new" be added to the end of Text-A or to the beginning of Text-B?

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×