Top Forums Shell Programming and Scripting Cut Number which appear before a delimiter Post 302138263 by Raynon on Sunday 30th of September 2007 08:40:23 PM
Hi manas_ranjan,

That's cool.

Can you explain your cut code ?
what does the -f1 mean ?

cut -d":" -f1

Test Your Knowledge in Computers #559
Difficulty: Easy
A runtime error is an error that occurs while a program is being executed.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

\r as delimiter in cut

I need to use \r as a delimiter in the -d option of the cut comand . Any help ? Thanks in advance . SD (5 Replies)
Discussion started by: shweta_d
5 Replies

2. UNIX for Advanced & Expert Users

Cut date using y hat as delimiter

QUESTION: How can I cut out the date from just the first line and reformat it to 31-Jul-2007? I'll restate the question at the bottom again... DESCRIPTION: I need to cut a date out of a file - an example of the date's format in the file is 2007-07-31. It's in the 5th field and is separated... (1 Reply)
Discussion started by: tekster757
1 Replies

3. Shell Programming and Scripting

CUT command delimiter in reverse

Hi, I've a situation where, a=xxx.yyy.zzz.txt EXTN=`echo $a | cut -d . -f2` Using the above code it delimites and will return "yyy.zzz.txt" to EXTN. But i need to get only the extension "txt". so as per the above code it delimits in the first "." itself. Can anyone help how to do... (6 Replies)
Discussion started by: skcvasanth
6 Replies

4. UNIX for Advanced & Expert Users

use a word as a delimiter with cut

Is there a way to use a word as a delimiter with cut? Or is there a way to use sed or awk with a word as a delimiter? I don't care which program I use for a delimiter I just want to use a word as a delimiter. (2 Replies)
Discussion started by: cokedude
2 Replies

5. Shell Programming and Scripting

cut -d with more than 1 delimiter?

I need to cut or otherwise get the 4th and 5th position output of for i in `date +%H` ; do vnstat --dumpdb | grep "h;$i" ; done example output is: h;13;1310318701;443;93 I only need ";443;93" from any given run of "for i in `date +%H` ; do vnstat --dumpdb | grep "h;$i" ; done" Thanks... (3 Replies)
Discussion started by: Habitual
3 Replies

6. Shell Programming and Scripting

Cut columns with delimiter

HI, I have a file like below "103865","103835","Zming","","Zhu","103965","Sunnyvale","US", "116228","116227","Morlla","","Kowalski","113228","Paese "(Treviso)""IT" I want to validate the 7th column which is below. "Sunnyvale" "Paese In the above 7th column Paese is not ended with... (9 Replies)
Discussion started by: Krrishv
9 Replies

7. Shell Programming and Scripting

how to cut all string after the last delimiter?

hi all, suppose a string: abc/def/ghi/jkl/mn.txt and i want to get the file name without the path. however, different files have different paths, therefore the number of delimiter is uncertain. thanks so much! (3 Replies)
Discussion started by: sunnydanniel
3 Replies

8. Shell Programming and Scripting

How to cut by delimiter, and delimiter can be anything except numbers?

Hi all, I have a number of strings like below: //mnt/autocor/4313'(33")W/ and i'm trying to get the numbers in this string, for example 431333 please help thanks ahead (14 Replies)
Discussion started by: sunnydanniel
14 Replies

9. Shell Programming and Scripting

cut delimiter and save

i have list of names in a text file and I wanted to delete the commas en every line. for example: inside the text is a list of names in it with commas after each line. I wanted to delete these commas. which command must I execute for this? unix, dale, shawn, aaron, (4 Replies)
Discussion started by: garfish
4 Replies

10. Shell Programming and Scripting

Cut cmd with delimiter as |#|

Hi All- We have a file data as below with delimiter as |#| 10|#|20|#|ABC 13|#|23|#|PBC If I want to cut the 2nd field out of this, below command is not working as multiple pipe is causing an issue , it seems cut -f2 -d"|#|" <file_name> can you please help to provide the correct command... (7 Replies)
Discussion started by: sureshg_sampat
7 Replies
CUT(1)							    BSD General Commands Manual 						    CUT(1)

cut -- cut out selected portions of each line of a file SYNOPSIS
cut -b list [-n] [file ...] cut -c list [file ...] cut -f list [-d delim] [-s] [file ...] DESCRIPTION
The cut utility cuts out selected portions of each line (as specified by list) from each file and writes them to the standard output. If no file arguments are specified, or a file argument is a single dash ('-'), cut reads from the standard input. The items specified by list can be in terms of column position or in terms of fields delimited by a special character. Column numbering starts from 1. The list option argument is a comma or whitespace separated set of numbers and/or number ranges. Number ranges consist of a number, a dash ('-'), and a second number and select the fields or columns from the first number to the second, inclusive. Numbers or number ranges may be preceded by a dash, which selects all fields or columns from 1 to the last number. Numbers or number ranges may be followed by a dash, which selects all fields or columns from the last number to the end of the line. Numbers and number ranges may be repeated, overlapping, and in any order. If a field or column is specified multiple times, it will appear only once in the output. It is not an error to select fields or columns not present in the input line. The options are as follows: -b list The list specifies byte positions. -c list The list specifies character positions. -d delim Use delim as the field delimiter character instead of the tab character. -f list The list specifies fields, separated in the input by the field delimiter character (see the -d option.) Output fields are separated by a single occurrence of the field delimiter character. -n Do not split multi-byte characters. Characters will only be output if at least one byte is selected, and, after a prefix of zero or more unselected bytes, the rest of the bytes that form the character are selected. -s Suppress lines with no field delimiter characters. Unless specified, lines with no delimiters are passed through unmodified. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of cut as described in environ(7). EXIT STATUS
The cut utility exits 0 on success, and >0 if an error occurs. EXAMPLES
Extract users' login names and shells from the system passwd(5) file as ``name:shell'' pairs: cut -d : -f 1,7 /etc/passwd Show the names and login times of the currently logged in users: who | cut -c 1-16,26-38 SEE ALSO
colrm(1), paste(1) STANDARDS
The cut utility conforms to IEEE Std 1003.2-1992 (``POSIX.2''). HISTORY
A cut command appeared in AT&T System III UNIX. BSD
December 21, 2006 BSD

Featured Tech Videos

All times are GMT -4. The time now is 03:53 PM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy