Solved

simple shell question

Posted on 2011-02-13
2
322 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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 …
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…

752 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