having issues in using Cut Command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers having issues in using Cut Command
# 1  
Old 10-27-2010
Power having issues in using Cut Command

Hi,

I would like to ask for your help with my problem,

im writing a unix script to remove characters before the symbol "/", but the one being removed are characters after the symbol. Ive searched over the internet and found no answer.. hope you can help me with this.

sample:
text file, temp.log contains:
Code:
file-sam-wizs/296596.pdf
file-sam-wizs/0307444.pdf
file-sam-001/362261.pdf
file-sam-001/362265.pdf
file-sam-001/362268.pdf
file-sam-001/362270.pdf
file-sam-001/362272.pdf
file-sam-001/362273.pdf
file-sam-3/362275.pdf
file-sam-3/362276.pdf
file-sam-3/362278.pdf
file-sam-3/362280.pdf
file-sam-003/362281.pdf
file-sam-3/362283.pdf
file-sam-4/362285.pdf
file-sam-004/362289.pdf
file-sam-004/362311.pdf
file-sam-004/362352.pdf
file-sam-4/362353.pdf
file-sam-4/362354.pdf
file-sam-002/362241.pdf
file-sam-002/362247.pdf
file-sam-002/362251.pdf
file-sam-002/362252.pdf
file-sam-002/362254.pdf
file-sam-002/362258.pdf

when i run the following command:

Code:
cut -d'/' -f 1,1 temp_file.log

This is the result,
Code:
file-sam-wizs
file-sam-wizs
file-sam-001
file-sam-001
file-sam-001
file-sam-001
file-sam-001
file-sam-001
file-sam-3
file-sam-3
file-sam-3
file-sam-3
file-sam-003
file-sam-3
file-sam-4
file-sam-004
file-sam-004

where the expected output should be:
Code:
 
296596.pdf
0307444.pdf
362261.pdf
362265.pdf
362268.pdf
362270.pdf
362272.pdf
362273.pdf
362275.pdf
362276.pdf
362278.pdf
362280.pdf
362281.pdf
362283.pdf
362285.pdf
362289.pdf
362311.pdf
362352.pdf
362353.pdf
362354.pdf
362241.pdf
362247.pdf
362251.pdf
362252.pdf
362254.pdf

Even if i change the value of -f 1,1 it has no effect. I would really appreciate your help guys..
thank you very much.
# 2  
Old 10-27-2010
Code:
cut -d '/' -f2 temp_file.log

These 2 Users Gave Thanks to vgersh99 For This Post:
# 3  
Old 10-27-2010
thank you very much!!! it worked!!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut command on RHEL 6.8 compatibility issues

We have a lot of scripts using cut as : cut -c 0-8 --works for cut (GNU coreutils) 5.97, but does not work for cut (GNU coreutils) 8.4. Gives error - cut: fields and positions are numbered from 1 Try `cut --help' for more information. The position needs to start with 1 for later... (6 Replies)
Discussion started by: Vikram Jain
6 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

Issues in sed command

I use SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux We have a user-defined command called "submit" which will open a vi terminal in which we need to enter the description at 24th line and save it. In order to simplify this, i decided to create another command in which the... (3 Replies)
Discussion started by: pandeesh
3 Replies

4. UNIX for Dummies Questions & Answers

Cut pid from ps using cut command

hay i am trying to get JUST the PID from the ps command. my command line is: ps -ef | grep "mintty" | cut -d' ' -f2 but i get an empty line. i assume that the delimiter is not just one space character, but can't figure out what should i do in order to do that. i know i can use awk or cut... (8 Replies)
Discussion started by: ran ber
8 Replies

5. Homework & Coursework Questions

sed & cut command issues

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: After using the egrep command to pull certain lines from the asg5f1 (creating the asg5f1c file), I am required... (1 Reply)
Discussion started by: robrom78
1 Replies

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

7. UNIX for Dummies Questions & Answers

mget command issues

Hi I am trying to get 3 files sitting on a FTP server to an application server. All 3 files are .csv files. I am using mget *.csv and it transfers only 2 files. the 3 files contain a common word in their file names "Report". I tried mget *Report*.csv and that gets me 2 files as well. ... (3 Replies)
Discussion started by: bobsn
3 Replies

8. UNIX for Dummies Questions & Answers

Issues I'm having with the Find Command

:confused: I've been trying to display all my files in my /tmp directory when I'm in it. I just can't get the darn find command working... And I've been trying to look at my /tmp directory on my home directory and I know I'm messing something up there.. Another issue I had while back but... (12 Replies)
Discussion started by: curtner
12 Replies

9. Shell Programming and Scripting

kill command issues

xxxxxx (8 Replies)
Discussion started by: kitty123
8 Replies

10. Shell Programming and Scripting

Issues with cut

We are running on a Sun cluster using ksh. We have a script that has been running for about six months with no issues. The script has not been modified and our results are now coming out diffrent. <BEGIN> cat $exfile | while read line do ... (1 Reply)
Discussion started by: bthomas
1 Replies
Login or Register to Ask a Question