Solved

simple shell question

Posted on 2011-02-13
2
318 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
ID: 34885450
perl -pe 's#^#@{[$ARGV=~/(\d{4})\./]} #' hits*.txt < all_hits.txt
0
 
LVL 1

Author Comment

by:aturetsky
ID: 34885473
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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