Cut command, no input delim, output delim not working


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cut command, no input delim, output delim not working
# 8  
Old 10-23-2014
Code:
$ cut -c1-2,4-5 -d --output-delimiter=| t.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
-bash: t.txt: command not found

If you use -d you must give it a char that represent the input delimiter, after it. You are not giving it anything. Otherwise, it takes "--output-delimiter=" as the parameter, which obviously is incorrect, it complains about it, and pipes it to t.txt as it were a program that accepts data, thus the -bash: t.txt: command not found

Last edited by Aia; 10-23-2014 at 05:42 PM..
This User Gave Thanks to Aia For This Post:
# 9  
Old 10-23-2014
edit: Nevermind. Don already posted the right cut command in post #4.
This User Gave Thanks to junior-helper For This Post:
# 10  
Old 10-23-2014
Quote:
Originally Posted by kojac
Aia, I tried!

Code:
$ cut -c1-2,4-5 -d --output-delimiter=| t.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
-bash: t.txt: command not found

Don Cragun, I tried!
$ cut -c1-2,4-5 -d --output-delimiter="|" t.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.

I'm wondering if it is the cygwin environment running on Windows 7!!

Don, the awk command worked nicely!! Much thanks to you both!!
Please look closely at what I suggested! There was no -d option in what I suggested and there were double quotes around the |. I'm glad the awk command worked, but you might also be able to use:
Code:
cut -c1-2,4-5 --output-delimiter="|" t.txt

This User Gave Thanks to Don Cragun For This Post:
# 11  
Old 10-23-2014
Hi Don,
I guess I've trying so many combinations of the command I automatically typed in the -d.

Your suggestion worked! Much much thanks!
+Kojac

---------- Post updated at 06:10 PM ---------- Previous update was at 06:02 PM ----------

Hi DG

I got it resolved, thanks for responding.
There was no input delim needed, (fixed length record) only wanted an output delim and the syntax got the better of me!
These 2 Users Gave Thanks to kojac For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Apply if condition to all lines of tab delim which have same value in a particular column:

Apply if condition (in column 3rd ) to all lines of tab delim which have same value in a particular column (in this case column2) Input: id1 Disease1 High id2 Disease1 Medium id3 Disease1 Low id4 Disease2 Low id5 Disease3 Medium id6 Disease3 Low *** Expected output id1 Disease1 High... (3 Replies)
Discussion started by: Lini
3 Replies

2. Shell Programming and Scripting

Why is my cut command not working ?

OS : RHEL 6.8 Shell : bash I want to remove all lines like below from the history output as it has password. $ history | grep sqlplus 239 sqlplus jn_usr/dxc825#@10.5.12.106/OCSGPD 256 sqlplus osb_soa/KD1egM09@10.5.12.196/BSOAPRD 279 sqlplus jn_usr/dxc825#@10.80.16.219/OCSGPD... (5 Replies)
Discussion started by: John K
5 Replies

3. Shell Programming and Scripting

Cut command not working in for loop

grep -Fxvf testdata.xls file_GTDA1.xls >file_GTDA.xls SLS_COUNT=`grep 'GTDA_Dly_Sls' file_GTDA.xls |wc -l` PMIX_COUNT=`grep 'GTDA_Dly_Pmix' file_GTDA.xls |wc -l` if ; then var1=`cat file_GTDA.xls|grep 'GTDA_Dly_Sls_'` var4="|" for i in $var1... (7 Replies)
Discussion started by: renuk
7 Replies

4. Shell Programming and Scripting

Assinging output of cut command

Hi, I have the files in the following files in a folder 19996587342 19487656550 19534838736 And i need to get the first 6 characters from the abvoe files so i used the following script #!/bin/ksh for i in 19* do txt= `$i | cut -c -6` echo "$txt" done The error is at... (4 Replies)
Discussion started by: smile689
4 Replies

5. UNIX for Dummies Questions & Answers

set output delimiter as tab in cut command

I can not make it work, it prints \t rather than introduce tabs. cut -d "," -f 4,8 Samples.csv --output-delimiter="\t" | sort > out Since I am running this command within a shell script, I tried manually inserting tab in this command, still does not work. I am using bash shell Suggestions... (8 Replies)
Discussion started by: analyst
8 Replies

6. Shell Programming and Scripting

korn shell to cut command output

hello, i use following command: md5sum TEST.xml the output looks like: 900hjidur84hjr938ikv TEST.xml as you can see, the first part is the md5 code, the second part is the file name, but i only want the first part(md5 code), and save it to a file, how to do that? thanks. (2 Replies)
Discussion started by: zbc
2 Replies

7. Shell Programming and Scripting

How to cut selected lines from command output

Hi guys, I need to cut the first 12 system processes from the command ps -A. I know that the cut command forms part of the pipeline but can't understand how to cut the first 12 lines and later display them on standard output. Please help! Many thanks, Jared. (3 Replies)
Discussion started by: jjb1989
3 Replies

8. Shell Programming and Scripting

delim count parsing

Hi all, I have an requirement related to delim count. I want to remove the lines having less than or equal to 2 fields in a csv file. In other words, I want to retrieve the records having more than 2 fields. I can do this using a loop with tr and wc -l command by parsing record by record.... (3 Replies)
Discussion started by: poova
3 Replies

9. UNIX for Dummies Questions & Answers

problem with output of find command being input to basename command...

Hi, I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script. I am planning to do like this: if ; then... (2 Replies)
Discussion started by: new_learner
2 Replies

10. UNIX for Dummies Questions & Answers

How can I cut output of command??

I am on a Linux system using bash shell. I only want to see the number in the Use% field as the output. #df -h / Filesystem Size Used Avail Use% Mounted on /dev/dasda1 2.3G 2.1G 51M 98% / !#/bin/bash df -h / | awk '{print $5}' | cut -c1-2 Us 98 How do... (2 Replies)
Discussion started by: darthur
2 Replies
Login or Register to Ask a Question