homepage Welcome to WebmasterWorld Guest from 54.234.159.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Merge Log Files (txt format)
Merge text files into one
Marlon




msg:4043226
 3:10 am on Dec 15, 2009 (gmt 0)

I log roll quite a bit and after collecting hundreds of txt files, I needed to combined these files into one. Not knowing unix or fancy vba, I had to find an app to do this.

After digging, I found bulk file merger. This neat little app managed to merge all my txt log files into one in a matter of seconds.
What a time saver....

 

phranque




msg:4043391
 12:30 pm on Dec 15, 2009 (gmt 0)

you can use the unix cat command for this.
here are some examples of usage:

cat file1 file2 file3 >bigfile (concatenates a list of files into one file)
cat *.txt >bigfile.txt (same but using wildcarding to list the files)
cat file.txt >>existingfile.txt (concatenating a file to the end of an existing file)

wheel




msg:4043431
 2:10 pm on Dec 15, 2009 (gmt 0)

The stuff you can do from the command line in linux is crazy. The difficult part is knowing the commands :).

Doing search and replace/text finding type of things are crazy easy.

I'm no expert but I routinely use the two following:
grep -R string *
which looks recursively for 'string' in every file, down into the directory structure. Looking for a bit of code? just type that at the top of the directory and it'll find it for you.

The other one I use is a search and replace:
perl -p -i -e 's/stringa/stringb/g' *
which replaces all occurrences of stringa with stringb. (I think this is called the perl 'pie' or something like that).

StupidScript




msg:4043774
 11:54 pm on Dec 15, 2009 (gmt 0)

wheel ... if you like the PERL, you ought'a love sed:

sed -i 's/searchfor/replacewith/g' *

Just sayin' ...

phranque




msg:4044025
 11:37 am on Dec 16, 2009 (gmt 0)

linux 101 day 1 includes these commands:
man
ls
rm
cat
grep
sed
for

a few of these commands with options open up another dimension:
grep -i
grep -v
grep -l
sed -n

be very (VERY) careful with:
rm -r
always (ALWAYS) do this first:
ls -r

then learn these operators:
(that would be the vertical bar which gets converted to a broken bar in this forum - uppercase backslash on a typical keyboard)
>
>>

that might cover at least 80-90% of your daily needs

if you also learn awk you can do some very sophisticated text processing without writing a program per se.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved