[SOLVED] Find and replace in one file with contents in a separate file
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Find and replace in one file with contents in a separate file
I am working with Volusion and want to change categories for products using libreoffice or by using bash as my info is in csv files. The problem is that my products download file shows categories only by id number (ie. 1, 2, 3, 4)
But I can download a separate categories file that has the id's in one column and the category name in another column.
I want to change the category id's in one file with the actual category name by using the data from the second file.
Here's an example:
---Product File---
Widget1 $19.95 1,3,5 ---Item is in 3 categories
Widget2 $24.95 2,4 ---this means it's in 2 categories
---Category File---
1 Books
2 Watches
3 Desks
4 Chairs
5 Doors
Hopefully this is possible to have my products file show up like this:
Widget1 $19.95 1,3,5 Books,Desks,Doors
Widget2 $24.95 2,4 Watches,Chairs
Is this even possible using libreoffice? If not, could I do this find and replace idea with a simple bash script?
I have 11,000 items and 1200 categories. This will save me a lot of time.
This seems to be a common sort of request - nothing in the "Similar threads" below ?.
Logic should be pretty straightforward - read the category file into an array, then use the numbers in the products records to index into the arrays and append the value. Personally I'd use awk.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.