Sponsored Content
Top Forums Shell Programming and Scripting Selecting Specific Columns and Insert the delimiter TAB Post 302547433 by birei on Monday 15th of August 2011 03:56:55 PM
Old 08-15-2011
A slice of the array content should work:
Code:
@arr = @arr[231 .. $#arr - 4];

It seems you have code like that, take a look to this example:
Code:
$ cat infile
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
$ cat script.pl
use warnings;
use strict;

my @arr = <>;
print "Before -> ", "@arr";
@arr = @arr[3 .. $#arr-2];
print "After -> ", "@arr";
$ perl script.pl infile
Before -> Monday
 Tuesday
 Wednesday
 Thursday
 Friday
 Saturday
 Sunday
After -> Thursday
 Friday

Regards,
Birei

Last edited by birei; 08-15-2011 at 05:03 PM..
This User Gave Thanks to birei For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cutting a tab delimiter file

I have a 30 column tab delimited record file. I need to extract the first 10column. The following command to cut was not working cut -f 1-10 -d "\t" filename. Could any one keep on this . Thanks in Advance (4 Replies)
Discussion started by: vinod.thayil
4 Replies

2. Shell Programming and Scripting

how to differentiate columns of a file in perl with no specific delimiter

Hi everybody, This time I am having one issue in perl. I have to create comma separated file using the following type of information. The problem is the columns do not have any specific delimiter. So while using split I am getting different value. Some where it is space(S) and some where it is... (9 Replies)
Discussion started by: Amiya Rath
9 Replies

3. Shell Programming and Scripting

append data in a file by using tab delimiter

Hi, I need to append the data in to a file by using tab delimiter. eg: echo "Data1" >> filename.txt echo "\t" >> filename.txt (its not working) echo "Data2" >> filename.txt. the result sould be like this. Data1 Data2 (6 Replies)
Discussion started by: Sharmila_P
6 Replies

4. UNIX for Advanced & Expert Users

how to search delimiter tab in a line and replace it

hi every one plz help me i want to search for a line contains tabspace This is a line The should be changed see the above line is seperated with tab space i want to replace that tab space in to # as This is a line#The should be changed i have tried with... (4 Replies)
Discussion started by: kkraja
4 Replies

5. UNIX for Dummies Questions & Answers

Delimiter: Tab or Space?

Hello, Is there a direct command to check if the delimiter in your file is a tab or a space? And how can they be converted from one to another. Thanks, G (4 Replies)
Discussion started by: Gussifinknottle
4 Replies

6. Shell Programming and Scripting

Selecting specific 'id's from lines and columns using 'SED' or 'AWK'

Hello experts, I am new to this group and to 'SED' and 'AWK'. I have data (text file) with 5 columns (C_1-5) and 100s of lines (only 10 lines are shown below as an example). I have to find or select only the id numbers (C-1) of specific lines with '90' in the same line (of C_3) AND with '20' in... (6 Replies)
Discussion started by: kamskamu
6 Replies

7. UNIX for Dummies Questions & Answers

Making a Tab delimiter file to Comma

How can i make a tab delimiter file to a comma delimiter??? (13 Replies)
Discussion started by: saggiboy10
13 Replies

8. Shell Programming and Scripting

Compare two tab-delimiter files

Hi, I have two files like: file1 chr1 40 chr1 50 chr2 10 chr2 60 file2 chr1 30 chr1 50 chr2 15 chr2 20 and want to get the difference of column 2 when column 1 is the same in both files. (4 Replies)
Discussion started by: linseyr
4 Replies

9. Shell Programming and Scripting

Insert space in specific column among many columns

Hello, I have some problem in inserting the space for the pairs of columns. I have the input file : I used this code below in replacing it using space in specific column (replace space in each two columns) sed -e "s/,/ /2" -e "s/,/ /3" inputfile Output showed : However, I have many... (3 Replies)
Discussion started by: awil
3 Replies

10. Shell Programming and Scripting

Delete and insert columns in a tab delimited file

Hi all , I have a file having 12 columns tab delimited . I need to read this file and remove the column 3 and column 4 and insert a word in column 3 as "AVIALABLE " Is there a way to do this . I am trying like below Thanks DJ cat $FILENAME|awk -F"\t" '{ print $1 "\t... (3 Replies)
Discussion started by: Hypesslearner
3 Replies
nl(1)								   User Commands							     nl(1)

NAME
nl - line numbering filter SYNOPSIS
/usr/bin/nl [-p] [-b [type]] [-d [delim]] [-f [type]] [-h [type]] [-i [incr]] [-l [num]] [-n [format]] [-s [sep]] [-w [width]] [-v [startnum]] [file] /usr/xpg4/bin/nl [-p] [-b type] [-d delim] [-f type] [-h type] [-i incr] [-l num] [-n format] [-s sep] [-w width] [-v startnum] [file] DESCRIPTION
The nl utility reads lines from the named file, or the standard input if no file is named, and reproduces the lines on the standard output. Lines are numbered on the left in accordance with the command options in effect. nl views the text it reads in terms of logical pages. Line numbering is reset at the start of each logical page. A logical page consists of a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently available for header, body, and footer. For example, -bt (the default) numbers non-blank lines in the body section and does not number any lines in the header and footer sections. The start of logical page sections are signaled by input lines containing nothing but the following delimiter character(s): +-----------------------------+-----------------------------+ | Line contents | Start Of | +-----------------------------+-----------------------------+ |::: |header | +-----------------------------+-----------------------------+ |:: |body | +-----------------------------+-----------------------------+ |: |footer | +-----------------------------+-----------------------------+ Unless optioned otherwise, nl assumes the text being read is in a single logical page body. OPTIONS
Command options may appear in any order and may be intermingled with an optional file name. Only one file may be named. The specified default is used when the option is not entered on the command line. /usr/xpg4/bin/nl options require option arguments. A SPACE character may separate options from option arguments. /usr/bin/nl options may have option arguments. If option-arguments of /usr/bin/nl options are not specified, these options result in the default. The supported options are: -btype Specifies which logical page body lines are to be numbered. Recognized types and their meanings are: a number all lines t number all non-empty lines. n no line numbering pexp number only lines that contain the regular expression specified in exp. See NOTES below. Default type for logical page body is t (text lines numbered). -ftype Same as -btype except for footer. Default type for logical page footer is n (no lines numbered). -ddelim The two delimiter characters specifying the start of a logical page section may be changed from the default characters (:) to two user-specified characters. If only one character is entered, the second character remains the default character (:). No space should appear between the -d and the delimiter characters. To enter a backslash, use two backslashes. -htype Same as -btype except for header. Default type for logical page header is n (no lines numbered). -iincr incr is the increment value used to number logical page lines. Default incr is 1. -lnum num is the number of blank lines to be considered as one. For example, -l2 results in only the second adjacent blank being numbered (if the appropriate -ha, -ba, and/or -fa option is set). Default num is 1. -nformat format is the line numbering format. Recognized values are: ln left justified, leading zeroes suppressed rn right justified, leading zeroes suppressed rz right justified, leading zeroes kept Default format is rn (right justified). -p Do not restart numbering at logical page delimiters. -ssep sep is the character(s) used in separating the line number and the corresponding text line. Default sep is a TAB. -vstartnum startnum is the initial value used to number logical page lines. Default startnum is 1. -wwidth width is the number of characters to be used for the line number. Default width is 6. OPERANDS
The following operand is supported: file A path name of a text file to be line-numbered. EXAMPLES
Example 1 An example of the nl command The command: example% nl -v10 -i10 -d!+ filename1 will cause the first line of the page body to be numbered 10, the second line of the page body to be numbered 20, the third 30, and so forth. The logical page delimiters are !+. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of nl: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
/usr/lib/locale/locale/LC_COLLATE/CollTable Collation table generated by localedef /usr/lib/locale/locale/LC_COLLATE/coll.so Shared object containing string transformation library routines ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/nl +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWesu | +-----------------------------+-----------------------------+ /usr/xpg4/bin/nl +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
pr(1), attributes(5), environ(5), regex(5), regexp(5), standards(5) NOTES
Internationalized Regular Expressions are used in the POSIX and "C" locales. In other locales, Internationalized Regular Expressions are used if the following two conditions are met: o /usr/lib/locale/locale/LC_COLLATE/CollTable is present. o /usr/lib/locale/locale/LC_COLLATE/coll.so is not present. Otherwise, Simple Regular Expressions are used. Internationalized Regular Expressions are explained on regex(5). Simple Regular Expressions are explained on regexp(5). SunOS 5.11 28 Mar 1995 nl(1)
All times are GMT -4. The time now is 02:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy