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 8518229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:55:26+00:00 2026-06-11T05:55:26+00:00

I have this kind of table: classA, s1, ss1 classA, s1, ss2 classA, s2,

  • 0

I have this kind of table:

classA, s1, ss1
classA, s1, ss2
classA, s2, ss1
classB, s1, ss1
classB, s1, ss2
classC, s1, ss1
classC, s2, ss1
classC, s2, ss2

Which I would like to split in 3 files called “classA”, “classB”, and “classC”, according to the consecutive values in 1st column. I tried first to find a way to do that using csplit, but it seems to work only on a specified pattern, not when the pattern changes. Is there any awk way or any other command-line tool to do that?

[UPDATE]
I have also some slashes in my 1st column that lead to that error, example:

classA, s1, ss1
classA, s1, ss2
classA, s2, ss1
classB, s1, ss1
classB, s1, ss2
classC, s1, ss1
classC, s2, ss1
classC, s2, ss2
classA/classA.1/classA.2, s1, ss1
classA/classA.1/classA.2, s1, ss2

And when I run the command:

awk -F, '{ print $0 > $1}' infile

It works with until “classC” but then I have that error because I guess it interprets the “/” as a path:

fatal: can't redirect to `classA/classA.1/classA.2' (No such file or directory)
  • 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-11T05:55:27+00:00Added an answer on June 11, 2026 at 5:55 am
    awk -F, '{ print $0 > $1}' infile 
    

    output

    -rw-r--r-- 1 shellter root  48 Sep 13 14:01 classC
    -rw-r--r-- 1 shellter root  32 Sep 13 14:01 classB
    -rw-r--r-- 1 shellter root  48 Sep 13 14:01 classA
    

    where $1 has “/…/path/info, try

    awk -F, '{ outFile="$1"; gsub(/\//, "", outFile); print $0 > outFile }' infile
    

    If you don’t do the gsub(), any ‘/’ chars will be intrepreted to follow a path to create the output file. Of course the path specfied will need to exist, or you’ll get error messages to that affect.

    Note that some awks prefer to have the ‘/’ char like gsub(/[\/]/,"", fileName), or you might even need [\\/] as the search target.

    IHTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this kind of table, it has many rows and each row has
guys i have arrays in which i have to match this kind of text
I have this kind of table: <table> <tr><td>Count A</td><td>12</td></tr> <tr><td>Count B</td><td>8</td></tr> </table> I'm new
I have something like this: class Person < ActiveRecord::Base has_many :things do def [](kind)
Suppose I have an entity like this: @Entity @Table(name = ITEMS) public class Item
I have this kind of question. In my form, i got this as a
I have this kind of node in my xml document: <parent ...> <a .../>
I have this kind of code below, how can I bind the visibility of
I have this kind of setup : Overridden BaseRunserverCommand that adds another option (--token)
I used to have this kind of simple JSON data and I could successfully

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.