Sponsored Content
Full Discussion: Concatenate Numerous Files
Operating Systems Linux Fedora Concatenate Numerous Files Post 302724829 by bakunin on Thursday 1st of November 2012 10:50:13 AM
Old 11-01-2012
Quote:
Originally Posted by sudon't
Code:
find /there/too -type f -name "*txt" -exec cmd {} \;

Oh, could we have just used this with cat in the first place? It's kinda like how I did it in the end, isn't it?
Yes and no: yes, in principle you could have done that. But you said you wanted to sort the files first, which is why i came up with the idea of the intermediate file, in which you could have sorted.

Still, alisters idea of guessing the filenames from a pattern was way better than mine, because it required a lot less handwork and still lead to the same result. Why it didn't work for you is still a mystery for me, i tried his solution with a dummy fileset and it worked well under Ubuntu 10, Fedora 13 and AIX 5.3. I have no MacOS to try it there, though, but from what i know this should make no difference.

Quote:
I learned what the gods really appreciate, from Homer.
Well said! I did the same, threw in some Epicurus for good measure and it didn't make me exactly unhappy.

I enjoyed the thread tremenduously, so thanks for asking questions and staying interested to the end. Whenever you want something to know we will be here to help again.

I hope this helps.

bakunin
 

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
glob(n) 						       Tcl Built-In Commands							   glob(n)

__________________________________________________________________________________________________________________________________________________

NAME
glob - Return names of files that match patterns SYNOPSIS
glob ?switches? pattern ?pattern ...? _________________________________________________________________ DESCRIPTION
This command performs file name "globbing" in a fashion similar to the csh shell. It returns a list of the files whose names match any of the pattern arguments. No particular order is guaranteed in the list, so if a sorted list is required the caller should use lsort. If the initial arguments to glob start with - then they are treated as switches. The following switches are currently supported: -directory directory Search for files which match the given patterns starting in the given directory. This allows searching of directories whose name contains glob-sensitive characters without the need to quote such characters explicitly. This option may not be used in conjunction with -path, which is used to allow searching for complete file paths whose names may contain glob-sensitive characters. -join The remaining pattern arguments are treated as a single pattern obtained by joining the arguments with directory separators. -nocomplain Allows an empty list to be returned without error; without this switch an error is returned if the result list would be empty. -path pathPrefix Search for files with the given pathPrefix where the rest of the name matches the given patterns. This allows searching for files with names similar to a given file (as opposed to a directory) even when the names contain glob-sensitive characters. This option may not be used in conjunction with -directory. For example, to find all files with the same root name as $path, but differing extensions, you should use glob -path [file rootname $path] .* which will work even if $path contains numerous glob-sensitive char- acters. -tails Only return the part of each file found which follows the last directory named in any -directory or -path path specification. Thus glob -tails -directory $dir * is equivalent to set pwd [pwd] ; cd $dir ; glob *; cd $pwd. For -path specifications, the returned names will include the last path segment, so glob -tails -path [file rootname ~/foo.tex] .* will return paths like foo.aux foo.bib foo.tex etc. -types typeList Only list files or directories which match typeList, where the items in the list have two forms. The first form is like the -type option of the Unix find command: b (block special file), c (character special file), d (directory), f (plain file), l (symbolic link), p (named pipe), or s (socket), where multiple types may be specified in the list. Glob will return all files which match at least one of the types given. Note that symbolic links will be returned both if -types l is given, or if the target of a link matches the requested type. So, a link to a directory will be returned if -types d was specified. The second form specifies types where all the types given must match. These are r, w, x as file permissions, and readonly, hidden as special permission cases. On the Macintosh, MacOS types and creators are also supported, where any item which is four characters long is assumed to be a MacOS type (e.g. TEXT). Items which are of the form {macintosh type XXXX} or {macintosh creator XXXX} will match types or creators respectively. Unrecognized types, or specifications of multiple MacOS types/creators will signal an error. The two forms may be mixed, so -types {d f r w} will find all regular files OR directories that have both read AND write permis- sions. The following are equivalent: glob -type d * glob */ except that the first case doesn't return the trailing "/" and is more platform independent. -- Marks the end of switches. The argument following this one will be treated as a pattern even if it starts with a -. The pattern arguments may contain any of the following special characters: ? Matches any single character. * Matches any sequence of zero or more characters. [chars] Matches any single character in chars. If chars contains a sequence of the form a-b then any character between a and b (inclu- sive) will match. x Matches the character x. {a,b,...} Matches any of the strings a, b, etc. On Unix, as with csh, a "." at the beginning of a file's name or just after a "/" must be matched explicitly or with a {} construct, unless the -types hidden flag is given (since "." at the beginning of a file's name indicates that it is hidden). On other platforms, files beginning with a "." are handled no differently to any others, except the special directories "." and ".." which must be matched explicitly (this is to avoid a recursive pattern like "glob -join * * * *" from recursing up the directory hierarchy as well as down). In addition, all "/" characters must be matched explicitly. If the first character in a pattern is "~" then it refers to the home directory for the user whose name follows the "~". If the "~" is followed immediately by "/" then the value of the HOME environment variable is used. The glob command differs from csh globbing in two ways. First, it does not sort its result list (use the lsort command if you want the list sorted). Second, glob only returns the names of files that actually exist; in csh no check for existence is made unless a pattern contains a ?, *, or [] construct. When the glob command returns relative paths whose filenames start with a tilde "~" (for example through glob * or glob -tails, the returned list will not quote the tilde with "./". This means care must be taken if those names are later to be used with file join, to avoid them being interpreted as absolute paths pointing to a given user's home directory. PORTABILITY ISSUES
Windows For Windows UNC names, the servername and sharename components of the path may not contain ?, *, or [] constructs. On Windows NT, if pattern is of the form "~username@domain", it refers to the home directory of the user whose account information resides on the speci- fied NT domain server. Otherwise, user account information is obtained from the local computer. On Windows 95 and 98, glob accepts pat- terns like ".../" and "..../" for successively higher up parent directories. Since the backslash character has a special meaning to the glob command, glob patterns containing Windows style path separators need spe- cial care. The pattern C:\foo\* is interpreted as C:foo* where f will match the single character f and * will match the single char- acter * and will not be interpreted as a wildcard character. One solution to this problem is to use the Unix style forward slash as a path separator. Windows style paths can be converted to Unix style paths with the command file join $path (or file normalize $path in Tcl 8.4). EXAMPLES
Find all the Tcl files in the current directory: glob *.tcl Find all the Tcl files in the user's home directory, irrespective of what the current directory is: glob -directory ~ *.tcl Find all subdirectories of the current directory: glob -type d * Find all files whose name contains an "a", a "b" or the sequence "cde": glob -type f *{a,b,cde}* SEE ALSO
file(n) KEYWORDS
exist, file, glob, pattern Tcl 8.3 glob(n)
All times are GMT -4. The time now is 10:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy