Sponsored Content
Top Forums Shell Programming and Scripting Printing from col x to end of line, except last col Post 302752883 by LMHmedchem on Monday 7th of January 2013 04:52:07 PM
Old 01-07-2013
Thanks, that worked fine and it's nice to have it in one step. Do you have any idea why the sed command doesn't work?

I was a bit unclear and I need to pass in a value for the string that will be replaced by "class", meaning it will not be C0014 every time.

Code:
SETS="C0014"
awk -F"\t" '{ if (!r) r=sub("$SETS","class"); $2=$NF OFS $2; NF--; } 1 ' OFS="\t"  'pass_'$SETS'_filter_.txt'  >  PASS1.txt

this does not work, so I guess I need to assign the value of $SETS to an awk variable???

LMHmedchem

Last edited by Franklin52; 01-08-2013 at 03:43 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Help On col command

Hello Can Any1 tell me the difference between the col command and the col command with the -f option. I tried running both of them but i can't see any difference. Please guide me. (1 Reply)
Discussion started by: rahulrathod
1 Replies

2. Shell Programming and Scripting

Setting Col size

I have a variable in a shell script which is more than 80 characters. 1) I log into SQL plus and populate a variable using 3 queries appended by ,' comma'. ORAINFO=`sqlplus -s << ! / as sysdba set feedback off set heading off select LOG_MODE... (2 Replies)
Discussion started by: yerra
2 Replies

3. UNIX for Dummies Questions & Answers

Info about col command

Hello every1. Can any1 help me with the col command. Wat is a reverse line feed. Which kind of files u need to use the col command. (2 Replies)
Discussion started by: rahulrathod
2 Replies

4. Ubuntu

Match col 1 of File 1 with col 1 File 2 and create a 3rd file

Hello, I have a 1.6 GB file that I would like to modify by matching some ids in col1 with the ids in col 1 of file2.txt and save the results into a 3rd file. For example: File 1 has 1411 rows, I ignore how many columns it has (thousands) File 2 has 311 rows, 1 column Would like to... (7 Replies)
Discussion started by: sogi
7 Replies

5. Shell Programming and Scripting

i can't cut the third col

SW_dist_intr false Enable SW distribution of interrupts True autorestart true Automatically REBOOT OS after a crash True boottype disk N/A False capacity_inc 1.00 ... (7 Replies)
Discussion started by: maxim42
7 Replies

6. UNIX for Advanced & Expert Users

Print line based on highest value of col (B) and repetion of values in col (A)

Hello everyone, I am writing a script to process data from the ATP world tour. I have a file which contains: t=540 y=2011 r=1 p=N409 t=540 y=2011 r=2 p=N409 t=540 y=2011 r=3 p=N409 t=540 y=2011 r=4 p=N409 t=520 y=2011 r=1 p=N409 t=520 y=2011 r=2 p=N409 t=520 y=2011 r=3 p=N409 The... (4 Replies)
Discussion started by: imahmoud
4 Replies

7. Shell Programming and Scripting

Retrieving data from 65th col (of each line) ?

Hello Friends, I am in situation where I have to note down few SQL queries from specific hexdump format. Here is an example (the query text starts at 65th character on each line) ---------------------- 0x000007FEB0E701C0 : 7365 6C65 6374 2063 7573 746E 6F2C 2020 select custno, ... (9 Replies)
Discussion started by: Sunusernewbie
9 Replies

8. Shell Programming and Scripting

Modifying col values based on another col

Hi, Please help with this. I have several excel files (with and .xlsx format) with 10-15 columns each. They all have the same type of data but the columns are not ordered in the same way. Here is a 3 column example. What I want to do add the alphabet from column 2 to column 3, provided... (9 Replies)
Discussion started by: newbie83
9 Replies

9. Shell Programming and Scripting

Merge files by col value

Hi, Please help, this is quite complex, I dont know how to start. The original input files are 10mb in size each. I have multiple files and I want to merge them in the following way. Every file has 4 columns. Col1 and col2 are fixed with respect to each other. In the example value A... (2 Replies)
Discussion started by: alpesh
2 Replies

10. Shell Programming and Scripting

Matrix to 3 col sorted

Hello experts, I have matrices sorted by position, there are 400k rows, 3000 columns. ID CHR POS M1 M2 M3 M4 M5 ID1 1 1 4.6 2.6 2.1 3.5 4.2 ID2 1 100 3.6 2.9 3.2 2.6 2.5 ID3 1 1000 4.1... (9 Replies)
Discussion started by: senhia83
9 Replies
COL(1)								   User Commands							    COL(1)

NAME
col - filter reverse line feeds from input SYNOPSIS
col [options] DESCRIPTION
col filters out reverse (and half-reverse) line feeds so the output is in the correct order with only forward and half-forward line feeds, and replaces white-space characters with tabs where possible. This can be useful in processing the output of nroff(1) and tbl(1). col reads from standard input and writes to standard output. OPTIONS
-b, --no-backspaces Do not output any backspaces, printing only the last character written to each column position. -f, --fine Forward half line feeds are permitted fine mode. Normally characters printed on a half-line boundary are printed on the following line. -p, --pass Force unknown control sequences to be passed through unchanged. Normally, col will filter out any control sequences from the input other than those recognized and interpreted by itself, which are listed below. -h, --tabs Output tabs instead of multiple spaces. -x, --spaces Output multiple spaces instead of tabs. -l, --lines number Buffer at least number lines in memory. By default, 128 lines are buffered. -V, --version Output version information and exit. -H, --help Output help and exit. NOTES
The control sequences for carriage motion that col understands and their decimal values are listed in the following table: ESC-7 reverse line feed (escape then 7) ESC-8 half reverse line feed (escape then 8) ESC-9 half forward line feed (escape then 9) backspace moves back one column (8); ignored in the first column newline forward line feed (10); also does carriage return carriage return (13) shift in shift to normal character set (15) shift out shift to alternate character set (14) space moves forward one column (32) tab moves forward to next tab stop (9) vertical tab reverse line feed (11) All unrecognized control characters and escape sequences are discarded. col keeps track of the character set as characters are read and makes sure the character set is correct when they are output. If the input attempts to back up to the last flushed line, col will display a warning message. SEE ALSO
expand(1), nroff(1), tbl(1) STANDARDS
The col utility conforms to the Single UNIX Specification, Version 2. The -l option is an extension to the standard. HISTORY
A col command appeared in Version 6 AT&T UNIX. AVAILABILITY
The col command is part of the util-linux package and is available from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils/util- linux/>. util-linux September 2011 COL(1)
All times are GMT -4. The time now is 01:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy