Sponsored Content
Top Forums Shell Programming and Scripting Cut between two delimiters, / and . Post 303039629 by wisecracker on Thursday 10th of October 2019 04:50:01 PM
Old 10-10-2019
You could try something like this too, except my "-f" value is "10":
Code:
#!/bin/bash
echo '10/10/19 13:47:24,unique,unique,5816-14-0-4756FAA-20181030000000-20181030000000-5817,4.900500,0.000000,2785,0,79,43645844,2801458,3,1376,79,16140365,11900137,5816,5817,4756FAA,14,0,
17835,17835,10/30/18,10/30/18,71,0,0,0,/mount/extract/output/unique/999FAAA.325.unique.unique,10/30/18 00:00:00,10/30/18 00:00:00,43645844' > /tmp/out.out

text=$( cut -d '/' -f 10 /tmp/out.out ); printf "%s\n" "${text%%.*}"

Results OSX 10.14.6, default bash terminal.
Code:
Last login: Thu Oct 10 21:41:52 on ttys000
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./cut_me.sh

999FAAA
AMIGA:amiga~/Desktop/Code/Shell> _

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut based on Two Delimiters at one go

Hi I wanted to cut the feilds comming after % and After $ at one go can we do some thing like this cut -f 2 -d "%|$" (But it doesnot work) Input File BWPG %TCPRP1 $SCSPR000 BWPH %TCPRP1 $SCSPR003 BWPI %TRTYUP ResourceDescription="IMPRIMANTE " $BWOPTY BWPJ %ZOMBIE ... (4 Replies)
Discussion started by: pbsrinivas
4 Replies

2. Shell Programming and Scripting

cut -- line with no delimiters

I just discovered, to my dismay, the following part of the cut man page: -f, --fields=LIST select only these fields; also print any line that contains no delimiter character, unless the -s option is specified The -s option toggles the printing of lines with no delimiters. In most... (3 Replies)
Discussion started by: chlorine
3 Replies

3. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

4. UNIX for Dummies Questions & Answers

Cut fields between delimiters

I'm having bother getting both lines contained in a file to output as the same value. A simple example: john:123456:123:456:doe john:123456:123:doe cut -d: -f1,4 input file john:456 john:doe ^ first line should be same as second. trick one for me, i know why it's because of the... (4 Replies)
Discussion started by: landofus
4 Replies

5. Shell Programming and Scripting

Cut counting consecutive delimiters as fields

When cut encounters consecutive delimiters it seems to count each instance as a field, at least with spaces. Is this typical behavior for any delimiter? #:~$ ifconfig eth0 | grep HWaddr eth0 Link encap:Ethernet HWaddr 94:de:80:a7:6d:e1 #:~$ ifconfig eth0 | grep HWaddr | cut -d " " -f... (6 Replies)
Discussion started by: Riker1204
6 Replies

6. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

7. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies
CUT(1)							      General Commands Manual							    CUT(1)

NAME
cut - select out columns of a file SYNOPSIS
cut [ -b | -c] list [file...] cut -f list [-d delim] [ -s] OPTIONS
-b Cut specified bytes -c Select out specific characters -d Change the column delimiter to delim -f Select out specific fields that are separated by the -i Runs of delimiters count as one -s Suppres lines with no delimiter characters, when used EXAMPLES
cut -f 2 file # Extract field 2 cut -c 1-2,5 file # Extract character columns 1, 2, and 5 cut -c 1-5,7- file # Extract all columns except 6 DESCRIPTION
[file...]" delimiter character ( see delim)" with the -f option. Lines with no delimiters are passwd through untouched" Cut extracts one or more fields or columns from a file and writes them on standard output. If the -f flag is used, the fields are sepa- rated by a delimiter character, normally a tab, but can be changed using the -d flag. If the -c flag is used, specific columns can be specified. The list can be comma or BLANK separated. The -f and -c flags are mutually exclusive. Note: The POSIX1003.2 standard requires the option -b to cut out specific bytes in a file. It is intended for systems with multi byte characters (e.g. kanji), since MINIX uses only one byte characters, this option is equivalent to -c. For the same reason, the option -n has no effect and is not listed in this man- ual page. SEE ALSO
sed(1), awk(9). CUT(1)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy