Sponsored Content
Full Discussion: Concatenate Numerous Files
Operating Systems Linux Fedora Concatenate Numerous Files Post 302723181 by sudon't on Monday 29th of October 2012 03:04:46 PM
Old 10-29-2012
I knew that, eventually, someone reading this thread would get frustrated and whip up a script to solve all my problems. It must be the same feeling I get when I meet someone who can barely read or write. Script writing is so far beyond my capabilities that it feels like cheating, somehow. ; )
The way they have the files set up might be a problem for your script. Indeed, it is thee problem.
Code:
-bash $ cat OTfilelistsorted.txt
.....
./01_Old Testament/01_Genesis/Genesis8.txt
./01_Old Testament/01_Genesis/Genesis9.txt
./01_Old Testament/01_Genesis/Genesis10.txt
./01_Old Testament/01_Genesis/Genesis11.txt
.....

Each book constitutes a directory, while each chapter constitutes a numbered file. Genesis, for instance, is broken up into fifty separate files. Correct me if I'm wrong, but it seems like your script is expecting each book to be one file. Could your embedded list contain a wildcard character? Even so, it seems to me we still have the problem of sorting. As you can see, they used single digit enumeration. But I'm going to try to fix the actual filenames, first.

---------- Post updated at 03:04 PM ---------- Previous update was at 02:36 PM ----------

OK, found out that rename is a perl script someone made up. Downloaded the code, et voila!
Code:
-bash $ ls
Genesis1.txt	Genesis19.txt	Genesis28.txt	Genesis37.txt	Genesis46.txt
Genesis10.txt	Genesis2.txt	Genesis29.txt	Genesis38.txt	Genesis47.txt
Genesis11.txt	Genesis20.txt	Genesis3.txt	Genesis39.txt	Genesis48.txt
Genesis12.txt	Genesis21.txt	Genesis30.txt	Genesis4.txt	Genesis49.txt
Genesis13.txt	Genesis22.txt	Genesis31.txt	Genesis40.txt	Genesis5.txt
Genesis14.txt	Genesis23.txt	Genesis32.txt	Genesis41.txt	Genesis50.txt
Genesis15.txt	Genesis24.txt	Genesis33.txt	Genesis42.txt	Genesis6.txt
Genesis16.txt	Genesis25.txt	Genesis34.txt	Genesis43.txt	Genesis7.txt
Genesis17.txt	Genesis26.txt	Genesis35.txt	Genesis44.txt	Genesis8.txt
Genesis18.txt	Genesis27.txt	Genesis36.txt	Genesis45.txt	Genesis9.txt
-bash $ ls | rename 's/(?<=[a-z])(?=[0-9]\.txt)/0/g'
-bash $ ls
Genesis01.txt	Genesis11.txt	Genesis21.txt	Genesis31.txt	Genesis41.txt
Genesis02.txt	Genesis12.txt	Genesis22.txt	Genesis32.txt	Genesis42.txt
Genesis03.txt	Genesis13.txt	Genesis23.txt	Genesis33.txt	Genesis43.txt
Genesis04.txt	Genesis14.txt	Genesis24.txt	Genesis34.txt	Genesis44.txt
Genesis05.txt	Genesis15.txt	Genesis25.txt	Genesis35.txt	Genesis45.txt
Genesis06.txt	Genesis16.txt	Genesis26.txt	Genesis36.txt	Genesis46.txt
Genesis07.txt	Genesis17.txt	Genesis27.txt	Genesis37.txt	Genesis47.txt
Genesis08.txt	Genesis18.txt	Genesis28.txt	Genesis38.txt	Genesis48.txt
Genesis09.txt	Genesis19.txt	Genesis29.txt	Genesis39.txt	Genesis49.txt
Genesis10.txt	Genesis20.txt	Genesis30.txt	Genesis40.txt	Genesis50.txt
-bash $

This should give us properly sorted lists. Now, a little find/replace to eliminate spaces.... I am now having fun.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting numerous files

Hi there, I have numerous files in a directory (approx 2500) that I want to delete although I get the following:- Server> rm *.* Arguments too long Is there a proper way of deleting this rather than breaking it down further through the list of files rm *10.* rm *11.* rm *12.* ... (10 Replies)
Discussion started by: Hayez
10 Replies

2. UNIX for Dummies Questions & Answers

How to concatenate all files.

Hi, I'm totally new to Unix. I'm an MVS mainframer but ran into a situation where a Unix server I have available will help me. I want to be able to remotely connect to another server using FTP, login and MGET all files from it's root or home directory, logout, then login as a different user and do... (1 Reply)
Discussion started by: s80bob
1 Replies

3. Shell Programming and Scripting

Script to concatenate several files

I need a script to concatenate several files in one step, I have 3 header files say file.S, file.X and file.R, I need to concatenate these 3 header files to data files, say file1.S, file1.R, file1.X so that the header file "file.S" will be concatenated to all data files with .S extentions and so on... (3 Replies)
Discussion started by: docaia
3 Replies

4. Shell Programming and Scripting

Concatenate rows in to 2 files

I have 2 files FILEA 1232342 1232342 2344767 4576823 2325642 FILEB 3472328 2347248 1237123 1232344 8787890 I want the output to go into a 3rd file and look like: FILEC 1232342 3472328 (1 Reply)
Discussion started by: unxusr123
1 Replies

5. Shell Programming and Scripting

Concatenate files

I have directory structure sales_only under which i have multiple directories for each dealer example: ../../../Sales_Only/xxx_Dealer ../../../Sales_Only/yyy_Dealer ../../../Sales_Only/zzz_Dealer Every day i have one file produce under each directory when the process runs. The requirement... (3 Replies)
Discussion started by: mohanmuthu
3 Replies

6. Shell Programming and Scripting

Concatenate files

Hi, I want to create a batch(bash) file to combine 23 files together. These files have the same extension. I want the final file is save to a given folder. Once it is done it will delete the 23 files. Thanks for help. Need script. (6 Replies)
Discussion started by: zhshqzyc
6 Replies

7. Shell Programming and Scripting

Concatenate files

I have a file named "file1" which has the following data 10000 20000 30000 And I have a file named "file2" which has the following data ABC DEF XYZ My output should be 10000ABC 20000DEF (3 Replies)
Discussion started by: bobby1015
3 Replies

8. UNIX for Dummies Questions & Answers

Concatenate Several Files to One

Hi All, Need your help. I will need to concatenate around 100 files but each end of the file I will need to insert my name DIRT1228 on each of the file and before the next file is added and arrived with just one file for all the 100files. Appreciate your time. Dirt (6 Replies)
Discussion started by: dirt1228
6 Replies

9. UNIX for Dummies Questions & Answers

Concatenate files

Hi I am trying to learn linux step by step an i am wondering can i use cat command for concatenate files but i want to place context of file1 to a specific position in file2 place of file 2 and not at the end as it dose on default? Thank you. (3 Replies)
Discussion started by: iliya24
3 Replies

10. UNIX for Dummies Questions & Answers

Concatenate files and delete source files. Also have to add a comment.

- Concatenate files and delete source files. Also have to add a comment. - I need to concatenate 3 files which have the same characters in the beginning and have to remove those files and add a comment and the end. Example: cat REJ_FILE_ABC.txt REJ_FILE_XYZ.txt REJ_FILE_PQR.txt >... (0 Replies)
Discussion started by: eskay
0 Replies
ECACCESS-FILE-MOVE(1p)					User Contributed Perl Documentation				    ECACCESS-FILE-MOVE(1p)

NAME
ecaccess-file-move - Move or Rename ECaccess Files SYNOPSIS
ecaccess-file-move -version|-help|-manual ecaccess-file-move [-debug] source-ecaccess-file target-ecaccess-file DESCRIPTION
Allow moving an ECaccess File. When the move occurs within the same ECaccess File System then it is a rename. When the move occurs across two different ECaccess File Systems then first a copy is done and then a delete of the original file is done (e.g. similar to ecaccess- file-copy ... -erase). The source-ecaccess-file and target-ecaccess-file are in the form [domain:][/user-id/]path. Please read the "Shell commands -> File Management" section of the "ecaccess" guide for more information on the ECaccess File System. ARGUMENTS
source-ecaccess-file The source ECaccess File name. target-ecaccess-file The target ECaccess File name. OPTIONS
-version Display version number and exits. -help Print a brief help message and exits. -manual Prints the manual page and exits. -debug Display the SOAP messages exchanged. EXAMPLES
ecaccess-file-move ec:test1.txt ec:test2.txt Rename the test1.txt file in the ECFS directory of the authenticated user in test2.txt. ecaccess-file-move ec:test1.txt home:test2.txt Copy the test1.txt file from the ECFS directory of the authenticated user to the test2.txt file in the $HOME directory of the authenticated user, then delete the test1.txt file from ECFS. SEE ALSO
ecaccess-file-delete, ecaccess-file-get, ecaccess-file-mget, ecaccess-file-modtime, ecaccess-file-mput, ecaccess-file-rmdir, ecaccess-file- copy, ecaccess-file-dir, ecaccess-file-mdelete, ecaccess-file-mkdir, ecaccess-file-chmod, ecaccess-file-put, ecaccess-file-size and ecaccess. perl v5.14.2 2012-04-16 ECACCESS-FILE-MOVE(1p)
All times are GMT -4. The time now is 10:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy