Sponsored Content
Operating Systems Linux Adding a prefix to a column using awk/sed commands Post 302483888 by bjorngill on Wednesday 29th of December 2010 12:30:05 AM
Old 12-29-2010
Adding a prefix to a column using awk/sed commands

Hello,

I am a newbie to linux and struggling to find a better way to append a column in a text file.
Here is the file i want to modify: It has 8 columns (and thousands of rows). I want to append the first column by adding "chr" infront of the numbers. Some rows have a string in the first column and I don't want to change them.
1 . miRNA 548816 548893 . + . ACC="MI0002023"; ID="dre-mir-155";
1 . miRNA 1651461 1651541 . + . ACC="MI0002180"; ID="dre-mir-459";
1 . miRNA 23269491 23269603 . - . ACC="MI0004786"; ID="dre-mir-740";
1 . miRNA 27656240 27656327 . + . ACC="MI0002052"; ID="dre-mir-218a-2";
1 . miRNA 34527751 34527843 . + . ACC="MI0004780"; ID="dre-mir-734";
1 . miRNA 40174414 40174523 . + . ACC="MI0010857"; ID="dre-mir-2197";
1 . miRNA 46862496 46862635 . - . ACC="MI0001895"; ID="dre-mir-16b";
1 . miRNA 46862739 46862822 . - . ACC="MI0001891"; ID="dre-mir-15a-1";
1 . miRNA 55355143 55355233 . - . ACC="MI0004765"; ID="dre-mir-722";
2 . miRNA 1085488 1085564 . + . ACC="MI0002181"; ID="dre-mir-460";
2 . miRNA 6031391 6031475 . + . ACC="MI0002000"; ID="dre-mir-137-1";
2 . miRNA 22105590 22105669 . - . ACC="MI0004782"; ID="dre-mir-736";
2 . miRNA 23568780 23568883 . - . ACC="MI0010841"; ID="dre-mir-2190";
2 . miRNA 25338635 25338716 . - . ACC="MI0001966"; ID="dre-mir-124-1";
2 . miRNA 31878456 31878533 . + . ACC="MI0001916"; ID="dre-mir-23a-3";
2 . miRNA 31880346 31880476 . + . ACC="MI0001928"; ID="dre-mir-27a";
2 . miRNA 34798348 34798457 . + . ACC="MI0010847"; ID="dre-mir-2198";
2 . miRNA 44164796 44164904 . - . ACC="MI0001366"; ID="dre-mir-181b-1";
2 . miRNA 57907954 57908073 . - . ACC="MI0001879"; ID="dre-mir-7a-3";


Is there any simple way to change the first column. Any help will be appreciated.

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk-adding a column to a file

Hello Friends, i used awk to sum up total size of files under a directory (with the help of examples, threads here). ls -l | awk '/^-/ {total += $5} END {printf "%15.0f\n",total}' >> total.txt After each execution of the script total result is appended into a text file: 7010 7794 8890 ... (7 Replies)
Discussion started by: EAGL€
7 Replies

2. Shell Programming and Scripting

sed/awk-adding numeric to a column

I have a txt file as follows Code: Oct 1 file1 4144 Oct 1 file23 5170 Oct 2 file5 3434 Oct 21 file56 2343 I need to add a new column by marking the right log file from current directory. For example populate like this. Please not in the second columt for "1" it has... (2 Replies)
Discussion started by: gubbu
2 Replies

3. UNIX for Dummies Questions & Answers

Adding a column with the row number using awk

Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
Discussion started by: cosmologist
4 Replies

4. Shell Programming and Scripting

Adding column using awk

Hello everyone, I have a file with the following structure: abc xyz 111 222 agf hjhf 787 799 tht yah 878 898 ... ... ... ... ... ... ... ... ... ... ... ... I want to add a column (with a fixed value of 1000) at the end such that it becomes: abc xyz 111 222 1000 agf hjhf 787... (5 Replies)
Discussion started by: ad23
5 Replies

5. Shell Programming and Scripting

Adding prefix to the values in the script

Hi, test.txt contains below values 1 2 3 4 5 Desired output: 'TT.1', 'TT.2', 'TT.3', 'TT.4', 'TT.5' Last value should not contain the comma after the value. Below is the script which i have tried. I'm using Linux. #!/bin/bash for i in $test.txt (4 Replies)
Discussion started by: venkatesht
4 Replies

6. UNIX for Dummies Questions & Answers

Adding Filename as column using sed

Hi , Can any one please tell me, how can we add the file name as column using sed. right now we are using the below awk command for adding the file name as column but when we are calling this script from datastage it is deleting the file data..very weird raised a support ticket with datastage.... (2 Replies)
Discussion started by: mora
2 Replies

7. Shell Programming and Scripting

AWK adding prefix/suffix to list of strings

75 103 131 133 138 183 197 221 232 234 248 256 286 342 368 389 463 499 524 538 (5 Replies)
Discussion started by: chrisjorg
5 Replies

8. Shell Programming and Scripting

Adding a specified value to a specified column - awk?

Hi everyone! I sometimes need to do some simple arithmetics, like adding a number to a certain column of a file. So I wrote a small function in the .bashrc file, which looks like this shifter() { COL=$1 VAL=$2 FILE=$3 cp $FILE $FILE.shifted awk 'NF==4 {$(( $COL )) = $(( $COL ))... (6 Replies)
Discussion started by: radudownload
6 Replies

9. UNIX for Dummies Questions & Answers

awk adding counts together from column

Hello Im new treat me nicely, I have a headache :) I have a script that seemed to work now it doesnt anyway, the last part is adding counts of unique items in a csv file eg 05492U34 38 05492U34 47 two columns, (many different values like this in file) i want... (7 Replies)
Discussion started by: aniquebmx
7 Replies

10. Shell Programming and Scripting

Need to add prefix using sed or awk from cat the file

I need the use sed or AWK using cat the file Node1 TDEV RW 1035788 TDEV RW 1035788 Server1 TDEV RW 69053 Server2 TDEV RW 69053 TDEV RW 103579 Server3 TDEV RW 69053 server4 RDF1+TDEV RW 69053 RDF1+TDEV RW 517894 RDF1+TDEV RW 621473 server6 TDEV RW 34526 TDEV RW 34526 (22 Replies)
Discussion started by: ranjancom2000
22 Replies
sane-microtek(5)						File Formats Manual						  sane-microtek(5)

NAME
sane-microtek - SANE backend for Microtek scanners DESCRIPTION
The sane-microtek library implements a SANE (Scanner Access Now Easy) backend that provides access to the "second generation" Microtek scanners. At present, the following hardware is known to work with this backend: Microtek ScanMaker E2, E3, E6 Microtek ScanMaker II, IIG, IIHR, IISP, III Microtek ScanMaker 35t, 35t+, 45t Microtek ScanMaker 600GS, 600ZS (see bug notes) Agfa StudioScan Agfa StudioScan II, StudioScan IIsi Agfa Arcus II (but not the "Arcus") Agfa DuoScan (premliminary) Vobis "Highscreen Realscan" Microtek Color PageWiz (preliminary) Transparent Media Adapter Document AutoFeeder The driver supports line art, halftone, 8bpp gray, and 24bpp color scans at normal and "expanded" resolutions (i.e. 1200x1200 on an E6), fast scans for color previews, and downloadable gamma tables. The supported scanners are all SCSI scanners. However, some parallel port models may work (under Linux), if they use a parport->scsi chip, and if you can find a scsi->parport driver. This is known to be the case for the Color PageWiz. The driver does not support the newest Microtek scanners, such as the V330 and V660, which use a new and very different SCSI-II command set. For those, try the alternate microtek2 backend. Most non-SCSI scanners would use the new command set. Most scanners newer than the Scanmaker E6 would use the new command set. If you own a Microtek scanner other than the ones listed above, tell us what happens --- see the BUGS section at the end of this document. Although this manual page is generally updated with each release, up-to-date information on new releases and extraneous helpful hints are available from the backend homepage: http://www.mir.com/mtek/ DEVICE NAMES
This backend expects device names of the form: special Where special is the UNIX path-name for the special device that corresponds to the scanner. The special device name must be a generic SCSI device or a symlink to such a device. Under Linux, such a device name could be /dev/sga or /dev/sge, for example. CONFIGURATION
The contents of the microtek.conf file is a list of device names that correspond to Microtek scanners. Empty lines and lines starting with a hash mark (#) are ignored. A sample configuration file is shown below: /dev/scanner # this is a comment /dev/sge The configuration file may also contain the special tokens norealcal or noprecal. norealcal will disable the use of magic, undocumented scanner calibration commands which are known to work on the E6, but may not work with other models. noprecal will disable logic which tries to avoid scanner precalibration. This logic would only have been activated if the magic calibration code was turned off. FILES
/etc/sane.d/microtek.conf The backend configuration file (see also description of SANE_CONFIG_DIR below). /usr/lib/sane/libsane-microtek.a The static library implementing this backend. /usr/lib/sane/libsane-microtek.so The shared library implementing this backend (present on systems that support dynamic loading). ENVIRONMENT
SANE_CONFIG_DIR This environment variable specifies the list of directories that may contain the configuration file. Under UNIX, the directories are separated by a colon (`:'), under OS/2, they are separated by a semi-colon (`;'). If this variable is not set, the configura- tion file is searched in two default directories: first, the current working directory (".") and then in /etc/sane.d. If the value of the environment variable ends with the directory separator character, then the default directories are searched after the explic- itly specified directories. For example, setting SANE_CONFIG_DIR to "/tmp/config:" would result in directories "tmp/config", ".", and "/etc/sane.d" being searched (in this order). SANE_DEBUG_MICROTEK If the library was compiled with debugging support enabled, this environment variable controls the debug level for this backend. A value of 128 requests maximally copious debug output; smaller levels reduce verbosity. SEE ALSO
sane(7), sane-scsi(5) AUTHOR
Matt Marjanovic BUGS
Known bugs/limitations are: Brightness and contrast broken. The 600GS is grayscale only, and will lock up if you select color. (Unfortunately, the 600GS and 600ZS are indistinguishable by software.) i.e. don't complain about these --- but if brightness and/or contrast do work for you, please tell me. If your scanner locks up, try setting the norealcal or noprecal option in the configuration file (first one, then both), and see if it helps. (If it does, report it.) Send lengthy bug reports and new scanner information to mtek-bugs@mir.com. All bug reports and new scanner inquiries should include an error log file. You can generate copious stderr output by setting the SANE_DEBUG_MICROTEK environment variable described above. For exam- ple: setenv SANE_DEBUG_MICROTEK 128 More general comments, suggestions, and inquiries about frontends or SANE should go to sane-devel@mostang.com, the SANE Developers mailing list. Have a look at http://www.mostang.com/sane/mail.html concerning subscription to sane-devel. February 8, 2000 sane-microtek(5)
All times are GMT -4. The time now is 02:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy