Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:23:44+00:00 2026-06-18T04:23:44+00:00

I have multiple tab delimited data files that are separated by month in the

  • 0

I have multiple tab delimited data files that are separated by month in the format jan06.txt, feb06.txt, ..., dec07.txt.

Within each file, it looks something like:

Header1 Header2 Header3 ...
Data1   Data2   Data3   ...
Data4   Data5   Data6   ...
...     ...     ...

What I want to do is to combine all all the data files into a single data file, with just a single header at the top, but also include a new data column that contains the month and year so I don’t lose that information from the file name. So my new, single data file would contain:

Date   Header1 Header2 Header3 ...
200601 Data1   Data2   Data3   ...
200602 Data4   Data5   Data6   ...
...    ...     ...     ...

Where 200601 would refer to Jan 06, 200602 refer to Feb 06, etc.

I know if I do something like cat *.txt > data.txt, I could combine all my files. However, the two issues remain:

  1. I have a header in every file that would get concatenated, which I don’t want.
  2. I would lose the month information that is stored in the file name.

I think I can do this with some combination of cat and sed, but I am not sure how to start.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:23:45+00:00Added an answer on June 18, 2026 at 4:23 am

    Try the following:

    function month() {
    
        case ${1:0:3} in
            "jan") echo "20${1:3:2}01" ;;
            "feb") echo "20${1:3:2}02" ;;
            "mar") echo "20${1:3:2}03" ;;
            "apr") echo "20${1:3:2}04" ;;
            "may") echo "20${1:3:2}05" ;;
            "jun") echo "20${1:3:2}06" ;;
            "jul") echo "20${1:3:2}07" ;;
            "aug") echo "20${1:3:2}08" ;;
            "sep") echo "20${1:3:2}09" ;;
            "oct") echo "20${1:3:2}10" ;;
            "nov") echo "20${1:3:2}11" ;;
            "dec") echo "20${1:3:2}12" ;;
        esac
    
    }
    
    # Header
    directory="your_directory/"
    echo -en "Date\t" > data.txt
    head -1 $(ls "${directory}"/*.txt | head -1) >> data.txt
    
    # Contents
    for file in "${directory}"/*.txt; do
    
        date="${file##*/}"
        date="$(month ${date%*.txt})\t"
        tail -n +2 ${file} | sed 's/^/'${date}'/' >> data.txt
    
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a lot of tab delimited data that is organized into multiple rows
I have multiple text files (.txt) with Tab delimited in a folder. The text
I have tab delimited data with multiple columns. I have OS names in column
I have a tab delimited table that has multiple columns (1500) and a few
I have a file that is tab-delimited and contains multiple tables each headed by
I have multiple tabs that have different data inside. The first tab has ListView
Let's say I have a tab-delimited text file that contains data arranged in columns
I have a tab delimited file that contains date, header row, some values, empty
I have a problem. Right now, a file that was supposed to be tab-delimited
I have HTTP header request and reply data in tab delimited form with each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.