removing a column from list

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing a column from list
# 1  
Old 10-08-2002
Question removing a column from list

What I am trying to do is figure out how to remove a column from a list in a file, or from the command line.

The opposite of cut -cX-Y file1

The file contains (result of who command)

jhabi0 pts/ta Oct 8 16:22
llemo0 pts/1 Oct 8 15:30
rgood0 pts/2 Oct 8 16:30
llemo0 pts/3 Oct 8 15:31
jlinc0 pts/tb Oct 8 16:31
rgood0 pts/4 Oct 8 16:10
jhabi0 pts/te Oct 8 09:17
cpacni pts/tf Oct 8 15:32
grenci pts/5 Oct 8 13:57
rhowa0 pts/th Oct 8 12:05
mmaha0 pts/tk Oct 8 15:40
grenci pts/7 Oct 8 13:58

and I would like to retrieve everything except (cut -c7-21)


Thanks in advance
# 2  
Old 10-08-2002
Sorry to anyone who gave this a thought. I just played around with the cut command and figured it out.

>who | cut -c1-7,31-38

gives me the login name and time logged in.
# 3  
Old 10-09-2002
i would lean toward awk.

who|awk '{ print $2 }'
# 4  
Old 10-09-2002
Actually this is what I had in mind.

who | awk '{ print $1 FS $5}'

Thanks for the awk lesson
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use regex on particular column (Removing comma from particular column)?

Hi, I have pipe separated file which contains some data having comma(,) in it. I want to remove the comma(,) only from particular column without changing data in other columns. Below is the sample data file, I want to remove the comma(,) only from 5th column. $ cat file1 ABC | DEF, HIJ|... (6 Replies)
Discussion started by: Prathmesh
6 Replies

2. UNIX for Dummies Questions & Answers

Creating a two column list of date pairs form a single column list

Hi all, looking for some help here. I'm what you'd call a dirty programmer. my shell scripts might be ugly, but they (usually) function... Say I have a single column text file with a list of dates (yyyymmdd) that represent the elevation of a point on that date (I work with land subsidence, so... (2 Replies)
Discussion started by: jbrandt1979
2 Replies

3. UNIX for Dummies Questions & Answers

Removing 2nd Column in Vi Editor

I have text like this M83-306 132 797 M83-312 145 685 M83-315 321 479 M83-319 654 193 M83-350 556 1184 M83-303 222 199 and I want to make it like this M83-306 797 M83-312 685 M83-315 ... (9 Replies)
Discussion started by: muhnandap
9 Replies

4. Shell Programming and Scripting

Removing first column using awk script

I have this awk script. I have two different methods to remove the first column. However defining method = 1 in the BEGIN produces different results than when defining method = 1 later on instead. Any idea what it might be doing differently??? :rolleyes: BEGIN { Version = "V05" ... (4 Replies)
Discussion started by: kristinu
4 Replies

5. Shell Programming and Scripting

Help in removing 1st column in file

Hi All, I have a input file CT;RE23;DR33;FT44 CT;RE24;DR22;FT55 Here i need to make and output file with below structure i need to remove the first column: RE23;DR33;FT44 RE24;DR22;FT55 How can i do this do i need to write a for loop for this Having 19 posts you should be... (12 Replies)
Discussion started by: kam786sim
12 Replies

6. Shell Programming and Scripting

Removing lines from one list from another list.

Hello, I was wondering if there was an easy way to take lines from a single-column list, and remove them from a second single-column list. For example, I want to remove the contents of list 1 from list 2. How would I do this? Contents of list 1: server1a server2b server3c server4a... (2 Replies)
Discussion started by: LinuxRacr
2 Replies

7. Shell Programming and Scripting

removing square braces from a particular column

Hey Guys, I have a text which has data like this Taaaa AAA BBB SSSS $ yelpi Taaaa mmmm kly Tnnnw $ meta Baaaa Qriek Trieh Mbjsd $ kingsq .... I need to get an output like this MAX AAA TEST BBB RES SSSS YUYT test MED yelpi (0 Replies)
Discussion started by: naveen@
0 Replies

8. UNIX for Dummies Questions & Answers

Removing last ten characters from a column

I have a file that looks like this: hsa-miR-517b-4373244 0 4.116 hsa-miR-886-5p-4395304 1.173 1.95 hsa-miR-551b-4380945 1.62 1.722 hsa-miR-886-3p-4395305 1.479 3.074 hsa-miR-125a-3p-4395310 1.246 2.697 hsa-miR-874-4395379 1.985 1.721 I want it too look like this: ... (9 Replies)
Discussion started by: e3r1ck_ETT
9 Replies

9. UNIX for Dummies Questions & Answers

Removing comma after 3rd column

I have 10,000 lines to remove the commas after the 3rd column. Any help will be appreciated! Removing commas after the 3rd column Input aaaaa,bbbbb,cccccc,ddddddd aaaaa,bbbbb,cccccc aaaaa,bbbbb,cccccc,ddddddd,eeeeee aaaaa,bbbbb,cccccc,ddddddd,eeeeee,fffffff........(limit of comma is not... (13 Replies)
Discussion started by: buddyme
13 Replies

10. Shell Programming and Scripting

Removing Headers and a Column

I have a text file in unix with a layout like this Column 1 - 1-12 Column 2 - 13-39 Column 3 - 40-58 Column 4 - 59-85 Column 5 - 86-120 Columbn 6 - 121-131 The file also has a header on the first 6 lines of each page. Each page is 51 lines long. So I want to remove the header from each... (30 Replies)
Discussion started by: DerangedNick
30 Replies
Login or Register to Ask a Question