help with cut command needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with cut command needed
# 1  
Old 11-15-2011
help with cut command needed

I have this file containing 8 veritcal lines and I need to cut the first two lines into a new file and then cut the next two lines into a new file and so on... any help would be much appreciated. I tried the cut -c but that doesnt work and I am not sure what else to try.
Thanks.
# 2  
Old 11-15-2011
If by vertical row, you mean something like this:


Code:
one  two three four five six seven eight
one  two three four five six seven eight
one  two three four five six seven eight

And you want all ones and twos in file1, all threes and fours in file2 etc. then this might work for you:


Code:
#!/usr/bin/env ksh
awk '
    {
        for( i = 1; i < NF; i += 2 )
        {
            of = sprintf( "file%s", int((i/2)+1) );
            printf( "%s %s\n", $(i), $(i+1) ) >of;
        }
    }
'
exit


It creates one file for every two columns in each input line.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

2. Shell Programming and Scripting

Help Needed Using awk/CUT

Hi Experts, I am writing a script and struct at a part Need your help to get this I have a file generated called /tmp/testify.log $ cat testify.log Machine Parts 6 DREE Mufler Strengths 33 XYNC Siscos 20 09 ABSC... (7 Replies)
Discussion started by: itsme488
7 Replies

3. UNIX for Dummies Questions & Answers

Cut pid from ps using cut command

hay i am trying to get JUST the PID from the ps command. my command line is: ps -ef | grep "mintty" | cut -d' ' -f2 but i get an empty line. i assume that the delimiter is not just one space character, but can't figure out what should i do in order to do that. i know i can use awk or cut... (8 Replies)
Discussion started by: ran ber
8 Replies

4. Shell Programming and Scripting

Help Needed! - Cut characters after a text string and append to end of filename

Hi all.. I have several unique files that contain one thing in common, and that is acct#. For all files in the directory, I want to append the 10 characters following the word "ACCOUNT:" to the end of the filename. for example: I have file 111_123 that contains ACCOUNT:ABC1234567 The file... (5 Replies)
Discussion started by: cinderella1
5 Replies

5. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

6. Shell Programming and Scripting

Cut Command Help Please

Hey Guys, I'm trying to use the cut command to do the following: "AuctionID","UserID","BidderRating","Bid","BidDateTime" 1070387924,"rmichaelll",46,407.00,2/12/2002 14:07:44 1070387924,"decocloxcolektor",155,402.00,2/12/2002 14:07:28 1070387924,"markartz",6,350.00,2/12/2002 11:11:52... (2 Replies)
Discussion started by: Gboy
2 Replies

7. Shell Programming and Scripting

cut command

HI, Bieng new to this forum not know how to start new thread. hence updating this thread on cut command. Please suggest delimter character for below scenario. Here is output of my df -kP command Filesystem 1024-blocks Used Available Capacity Mounted on... (1 Reply)
Discussion started by: nileshjori
1 Replies

8. UNIX for Dummies Questions & Answers

Cut help needed!!!!!!

cut help needed!!!!! -------------------------------------------------------------------------------- /home/documents/files/scooter17.dat I am trying to cut out everything upto scooter17.dat so that it will only print out the scooter17.dat any ideas? great advices will be greatly... (1 Reply)
Discussion started by: scooter17
1 Replies

9. UNIX for Dummies Questions & Answers

cut help needed!!!!!

/home/documents/files/scooter17.dat I am trying to cut out everything upto scooter17.dat so that it will only print out the scooter17.dat any ideas? great advices will be greatly appreciated. Thank you ********Updated*************** Thank you for the replys. It works!!... (4 Replies)
Discussion started by: scooter17
4 Replies
Login or Register to Ask a Question