how to use cut -f commant in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to use cut -f commant in unix
# 1  
Old 06-23-2005
how to use cut -f commant in unix

Hi all,

I am desperately seeking help from you guys, on "cut -f" command.

actually i want to cut a line into different parts and align column wise in the output

so i use the command cut -f1,3,5 <filename>

so in this case, my output should be first column<tab>third column<tab>fifth column

i tried this command but didnt work, can u help me out pls.

Thanks
Vasikaran
# 2  
Old 06-23-2005
Show a sample of how your input would look like.

vino
# 3  
Old 06-23-2005
sample output

see , if my file contains the data like

I am a nice guy working for a company
U r a nice person working on my problem

if is give command like cut -f1,3,5,7 <file name >

the output shd be

I a guy for
U a person on

This is shd be my ouput, so the above command is not working, so how do i go abt it
# 4  
Old 06-23-2005
Here's the cut

Code:
 cut -d" " -f1,3,5,7 < input.txt

vino
# 5  
Old 06-23-2005
hope this helps

cut -f1,3,5,7 -d" " <filename>
# 6  
Old 06-23-2005
thanks yaar it is working

Hi Vino, Madan

Thank you so much, it is working, ...

very happy and great support ...

thanks a ton..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

UNIX shell script - cut specified line and perform loop

Guys, I have a requirement as below. consider,if i use df command, its getting the below output. file system kbytes used avail %used Mounted on /dev/sample/ 45765 40000 5765 50% / /dev/filesys/ 30000 20000 1000 80% /u .... .... Now i wanted to cut the /u... (11 Replies)
Discussion started by: AraR87
11 Replies

3. UNIX for Dummies Questions & Answers

cut/fgrep (UNIX utilities)

Hi I need to download unix utilities for my windows OS as i need to use cut/fgrep command. Can any one help me with this please. Thanks a lot (1 Reply)
Discussion started by: syseq
1 Replies

4. 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

5. Shell Programming and Scripting

Unix Cut or Awk from 'Right TO Left'

Hello, I want to get the User Name details of a user from a file list. This list can be in the format: FirstName_MiddleName1_LastName_ID FirstName_LastName_ID FirstName_MiddleName1_MiddleName2_LastName_ID What i want it to return is FirstName_MiddleName1_LastName of a user. I... (6 Replies)
Discussion started by: limamichelle
6 Replies

6. Shell Programming and Scripting

cut first line in unix

Hi I need to cut the first line of a line and append it at last of the same file, when i run the script for the second time.. plz help on this.. thanks (1 Reply)
Discussion started by: raghulshekar
1 Replies

7. Shell Programming and Scripting

Problem with UNIX cut command

#!/usr/bin/bash cat /etc/passwd | while read A do USER=`echo “$A” | cut -f 1 -d “:”` echo “Found $USER” done This shell script should make USER = the first field of the first line of the file /etc/passwd Eg: adm daemon bob jane kev etc ... However USER=echo... (3 Replies)
Discussion started by: kevin80
3 Replies
Login or Register to Ask a Question