Sponsored Content
Top Forums Shell Programming and Scripting removing a delimiter at the start of row Post 302142069 by Yogesh Sawant on Wednesday 24th of October 2007 06:58:24 AM
Old 10-24-2007
Not a very efficient solution:
Code:
echo ":1:2:2:3:3:4" |  cut -c 2-

Get everything from second character onwards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help with sed to add delimiter and new field to each row

I have a file with millions of rows that I need to add a delimiter and a new field with a zero to the end of each row. (its too big to open and do a find and replace regex) I'm looking for the next line '\n' and need to replace it with a Unit Separator (hex \037) 0 \n. I've tried the... (2 Replies)
Discussion started by: kmac
2 Replies

2. Shell Programming and Scripting

removing files with certain number in the first row

Hello! I have 32000 files in a directory and want to remove those with first row beging with 0.00; file names are in numbers from 1 through 32000; I have coded the following but it gives me error: while ( i <= 32000 ) if (head -1 $i ==0.00) rm $i end Well, i am sure even if this... (14 Replies)
Discussion started by: nxp
14 Replies

3. Shell Programming and Scripting

Counting number of records with string row delimiter

HI, i have a file like this t.txt f1|_f2|_ f1|_f2|_ f1|_f2|_ as if col delimiter is |_ and row delimiter |_\n trying to count number of records using awk $ awk 'BEGIN{FS="|_" ; RS="~~\n"} {n++}END{print n} ' t.txt 7 wondering how can i count this to 3 ? thx (9 Replies)
Discussion started by: aksforum
9 Replies

4. Shell Programming and Scripting

Column to row with delimiter

Hi, i have data in a file f1.txt a b c d and i want to print the above column values in single line with a delimiter, say ',' The output should look like: a,b,c,d I could find rows to columns help online but not vice versa Thanks, -srinivas yelamanchili (4 Replies)
Discussion started by: ysrini
4 Replies

5. Shell Programming and Scripting

Removing un-necessary start string

i have input in below form part=gfjhwhedaqh=ghdgwg^*^(G== i want to remove the starting "part=" and retain the remaining. please suggest (4 Replies)
Discussion started by: skyineyes
4 Replies

6. Shell Programming and Scripting

Convert row to columns start from nth column

Dear All, We have input like this: 161 57 1378 176 1392 262 1444 441 1548 538 1611 670 1684 241 57 1378 208 1393 269 1447 444 1549 538 1610 677 1700 321 ... (4 Replies)
Discussion started by: attila
4 Replies

7. Shell Programming and Scripting

Removing duplicate lines on first column based with pipe delimiter

Hi, I have tried to remove dublicate lines based on first column with pipe delimiter . but i ma not able to get some uniqu lines Command : sort -t'|' -nuk1 file.txt Input : 38376KZ|09/25/15|1.057 38376KZ|09/25/15|1.057 02006YB|09/25/15|0.859 12593PS|09/25/15|2.803... (2 Replies)
Discussion started by: parithi06
2 Replies

8. Shell Programming and Scripting

Split a file by start and end row.

I have a file which looks something as following, I would like to split to several files, The start and end of each file is 'FILE' and end with 'ASCII... ' . At the same time for each file in the first column add 100 and also second column add 100 the rest of the column as it is , see example of... (2 Replies)
Discussion started by: tk2000
2 Replies

9. Shell Programming and Scripting

Count delimiter(~|*) each row in a file and return 1 or 0

Hi I want to check delimiter in file. Delimiter in my file is ~|* sample of file : ABC~|*edgf~|*T1J333~|*20121130 ABC~|*sdaf~|*T1J333~|*20121130 ABC~|*fsdg~|*T1J333~|*20121130 ABC~|*dfsg~|*T1J333~|*20121130 in this i want to count number delimiter occur is 4 in each row if count is... (21 Replies)
Discussion started by: MOHANP12
21 Replies

10. Shell Programming and Scripting

Split files based on row delimiter count

I have a huge file (around 4-5 GB containing 20 million rows) which has text like: <EOFD>11<EOFD>22<EORD>2<EOFD>2222<EOFD>3333<EORD>3<EOFD>44<EOFD>55<EORD>66<EOFD>888<EOFD>9999<EORD> Actually above is an extracted file from a Sql Server with each field delimited by <EOFD> and each row ends... (8 Replies)
Discussion started by: amvip
8 Replies
cut(1)								   User Commands							    cut(1)

NAME
cut - cut out selected fields of each line of a file SYNOPSIS
cut -b list [-n] [file...] cut -c list [file...] cut -f list [-d delim] [-s] [file...] DESCRIPTION
Use the cut utility to cut out columns from a table or fields from each line of a file; in data base parlance, it implements the projection of a relation. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option) or the length can vary from line to line and be marked with a field delimiter character like <TAB> (-f option). cut can be used as a filter. Either the -b, -c, or -f option must be specified. Use grep(1) to make horizontal ``cuts'' (by context) through a file, or paste(1) to put files together column-wise (that is, horizontally). To reorder columns in a table, use cut and paste. OPTIONS
The following options are supported: list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)). -b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. -c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line). -d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. delim can be a multi-byte character. -f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (use- ful for table subheadings), unless -s is specified. -n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split. -s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched. OPERANDS
The following operands are supported: file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used. USAGE
See largefile(5) for the description of the behavior of cut when encountering files greater than or equal to 2 Gbyte (2**31 bytes). EXAMPLES
Example 1: Mapping user IDs A mapping of user IDs to names follows: example% cut -d: -f1,5 /etc/passwd Example 2: Setting current login name To set name to current login name: example$ name=`who am i | cut -f1 -d' '` ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 All input files were output successfully. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
grep(1), paste(1), attributes(5), environ(5), largefile(5), standards(5) DIAGNOSTICS
cut: -n may only be used with -b cut: -d may only be used with -f cut: -s may only be used with -f cut: cannot open <file> Either file cannot be read or does not exist. If multiple files are present, processing continues. cut: no delimiter specified Missing delim on -d option. cut: invalid delimiter cut: no list specified Missing list on -b, -c, or -f option. cut: invalid range specifier cut: too many ranges specified cut: range must be increasing cut: invalid character in range cut: internal error processing input cut: invalid multibyte character cut: unable to allocate enough memory SunOS 5.10 29 Apr 1999 cut(1)
All times are GMT -4. The time now is 09:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy