Sponsored Content
Full Discussion: cut column
Top Forums Shell Programming and Scripting cut column Post 302156541 by ust on Tuesday 8th of January 2008 12:10:08 PM
Old 01-08-2008
cut column

I have a file as below,

$vi myfile

aaa;20071217
bbb;20070404
ccc;20070254
"



if I want to cut the column 9-12 of the first line , the output should be 1217 , can advise how to write a script to get the result ? thx

p.s. can a script that have only ONE line could do that ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cut the third column from a file

I have a text file which has the following data. There can be more lines in the file. But, I am only interested in these two lines which has ~ZZ~VISTN and ~ZZ~F159B segments. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< ... (8 Replies)
Discussion started by: isingh786
8 Replies

2. Shell Programming and Scripting

To cut entire column from a file and apend it to another file as another column

file1.txt : india pakistan bangladesh japan canada africa USA srilanka Nepal file2.txt Delhi Tokyo washington I have to cut the first column of file1.txt and apend it with file2.txt as another column like this Delhi india Tokyo japan washington USA ... (4 Replies)
Discussion started by: sakthifire
4 Replies

3. UNIX for Advanced & Expert Users

cut a specific value from a column

Dear Friends, I have an output like this: 7072;0;7072901 7072;1001;7072902 7072;101;7072903 7072;102;7072904 7072;1101;7072905 7072;1301;7072906 7072;1401;7072907 7072;162;7072908 7072;1;7072909 and I need to print the value in the column 3 , row number 1. which is 7072901 only.... (2 Replies)
Discussion started by: sfaqih
2 Replies

4. Shell Programming and Scripting

how to cut off last column from the output

I have a problem with my script. I am using following code awk -F"," '{print $0,",",substr($2,3,3)}' $REG_InputFileName > $TargetSeqPath/Master.tmp while read i do echo $i > $TargetSeqPath/Ref.tmp OutFileName=`awk -F"," '{print $3}' $TargetSeqPath/Ref.tmp` rm -f... (9 Replies)
Discussion started by: manmeet
9 Replies

5. Shell Programming and Scripting

cut the first row first column value

Hi All, file create2.txt contains . /test.txt ./create.txt ./test2.txt test.txt contains inb-1|kuuhsdkjfhsd|djshfjksd|ndsbs896 inb-2|kuuhsdkjfhsd|djshfjksd|ndsbs896 inb-3|kuuhsdkjfhsd|djshfjksd|ndsbs896create.txt contains abv-1|kjsdgfjksd|sdkjbfhokjsd|skjdbfhjkosd... (8 Replies)
Discussion started by: adaleru
8 Replies

6. Shell Programming and Scripting

cut the last column from the link

Hi, I need to cut the last of below link lrwxrwxrwx 1 e027025 denccefs 36 Oct 21 02:30 prodcode1 -> /efare1/LINUXMTP-4/HOTFIX111019A_5U4/ after cut I need this value HOTFIX111019A_5U4 Please help me. Thanks (3 Replies)
Discussion started by: rohit22hamirpur
3 Replies

7. Shell Programming and Scripting

Pick the column value based on another column using awk or CUT

My scenario is that I need to pick value from third column based on fourth column value, if fourth column value is 1 then first value of third column.Third column (2|3|4|6|1) values are cancatenated. Please someone help me to resolve this issue. Source column1 column2 column3 column4... (2 Replies)
Discussion started by: Ganesh L
2 Replies

8. UNIX for Dummies Questions & Answers

Cut the two column from non delimited file

Hi, I have a question how to cut the column from non delimited file This is my file gene_id ENSG00000223972 transcript_id ENST00000456328 exon_number 1 gene_biotype pseudogene gene_name DDX11L1 transcript_name DDX11L1-002 tss_id TSS26614 gene_id ENSG00000223972 transcript_id ENST00000515242... (1 Reply)
Discussion started by: Wan Fahmi
1 Replies

9. Shell Programming and Scripting

Cut first column from file in Vi(Vim)

I have a parts file that looks like this: EE36264|0NH46||Y|A|EA|0|0|0|N|LUNETTE 3" ADJ. EYE|0|0|*|0|PEOZZU|N|12|N|N|VPS|N|N|N|N|LUNETTE 3" ADJ. EYE|0|||Receive into Inventory|81755|EE36264|*|*|*|0|0||EE36264|A|*|* F1.5|53932||Y|A|EA|0|0|0|N|FLAT ZERO CAL... (4 Replies)
Discussion started by: djehresmann
4 Replies

10. Shell Programming and Scripting

Cut each column value and store in variable

Hi Pals, I have a file which contains a set of similar lines, as follows: Remedy Support Action Triggered by Incident Modification of type: ARA username2 ########## ARA|INC0000178532 INC0000178532 0000000019879 000000000038372 Remedy... (6 Replies)
Discussion started by: Khushbu
6 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 indi- cate 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 (useful 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.11 29 Apr 1999 cut(1)
All times are GMT -4. The time now is 10:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy