Solved

simple shell question

Posted on 2011-02-13
2
311 Views
Last Modified: 2012-08-13
I have files in the following format.
hits0114.txt   (0114 means January 14).
hits0115.txt
hits0116.txt

and so on.

inside each file I have two columns, like this

  94125 0
   8063 -1
  41548 10
   5182 4
  29374 7
   2913 8
   3373 9


How would I concatenate these files and create one file all_hits.txt where

the first column is the date in ddmm format (same as above)
and the second and the third columns are the two columns mentioned above
0
Comment
Question by:aturetsky
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
perl -pe 's#^#@{[$ARGV=~/(\d{4})\./]} #' hits*.txt < all_hits.txt
0
 
LVL 1

Author Comment

by:aturetsky
Comment Utility
perfect - just what I asked for!

just to notch it up a bit - is it possible in the output file to put the date in a mm/dd format - i.e. 01/30
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now