help required with cut -d


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help required with cut -d
# 1  
Old 11-27-2006
help required with cut -d

i have a file in which data is like this

12 34 56 78
78 56 34 12

now i want to cut 2nd last column....

if 2nd column from start is to be cut then i can write

cut -d" " -f2 filename

what to do if 2nd column from end is to be cut !

any help

thanks
Sidhu
# 2  
Old 11-27-2006
Do you have to use cut? awk will work very well here.
Code:
echo "12 34 56 78
78 56 34 12" | awk '{print $(NF-1)}'

# 3  
Old 11-27-2006
with cut

is there any way we can do it with cut ?

also with awk if i need to read from file then how m going to do it...couldnt get a clue...actually touching linux after long time Smilie
# 4  
Old 11-27-2006
try this

Code:
cat file_name | awk '{print $(NF-1)}'

# 5  
Old 11-27-2006
thanks !

thanks Smilie
it is perfect !
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. 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

3. Shell Programming and Scripting

Need to cut a some required data from file

Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: ORA-00942: table or view does not exist I have some thing like above in the file.. Upto this portion Data_Consolidation_Engine_Part_2_Job2..TgtArBkt: the length can be vary .. Can some one help me in taking this portion alone ORA-00942:... (7 Replies)
Discussion started by: saj
7 Replies

4. Shell Programming and Scripting

Help required the cut the whole contents from one file and paste it into new file

Hi, First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong ! I am very new to UNIX scripting. Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :- Code :- (Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies

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

6. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

7. Shell Programming and Scripting

Help required using cut command

Hi all, I have one text as '/home/psv/file/test.ksh'. In that I want to cut the text as '/home/psv/file/' . Let me know which command to use. Thanks Mahalakshmi.A (4 Replies)
Discussion started by: mahalakshmi
4 Replies
Login or Register to Ask a Question