cut help needed!!!!!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cut help needed!!!!!
# 1  
Old 08-14-2006
cut help needed!!!!!

/home/documents/files/scooter17.dat

I am trying to cut out everything upto scooter17.dat so that it will only print out the scooter17.dat

any ideas?
great advices will be greatly appreciated.

Thank you


********Updated***************
Thank you for the replys. It works!! However, I am trying to do that for all the folders I have, meaning /home/documents/downloads/file1.dat and so on. So is there a way for me to write on script that only prints out the file name(file1.dat) for all the folders I have?

Thank you

Last edited by scooter17; 08-15-2006 at 11:04 AM..
# 2  
Old 08-14-2006
Quote:
Originally Posted by scooter17
/home/documents/files/scooter17.dat

I am trying to cut out everything upto scooter17.dat so that it will only print out the scooter17.dat

any ideas?
great advices will be greatly appreciated.

Thank you
what exactly are you trying?
# 3  
Old 08-14-2006
try this

$ ls lst where lst is the file you are working with
lst
$ cat lst
/export/home/prdcnlt2
$ cut -d/ -f4 lst
prdcnlt2
# 4  
Old 08-14-2006
# basename /home/documents/files/scooter17.dat
scooter17.dat
# 5  
Old 08-15-2006
Using built-ins:
Code:
file=/home/documents/files/scooter17.dat
echo ${file##*/}

 
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

Help Needed Using awk/CUT

Hi Experts, I am writing a script and struct at a part Need your help to get this I have a file generated called /tmp/testify.log $ cat testify.log Machine Parts 6 DREE Mufler Strengths 33 XYNC Siscos 20 09 ABSC... (7 Replies)
Discussion started by: itsme488
7 Replies

4. Shell Programming and Scripting

Help Needed! - Cut characters after a text string and append to end of filename

Hi all.. I have several unique files that contain one thing in common, and that is acct#. For all files in the directory, I want to append the 10 characters following the word "ACCOUNT:" to the end of the filename. for example: I have file 111_123 that contains ACCOUNT:ABC1234567 The file... (5 Replies)
Discussion started by: cinderella1
5 Replies

5. Shell Programming and Scripting

help with cut command needed

I have this file containing 8 veritcal lines and I need to cut the first two lines into a new file and then cut the next two lines into a new file and so on... any help would be much appreciated. I tried the cut -c but that doesnt work and I am not sure what else to try. Thanks. (1 Reply)
Discussion started by: drew211
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

Cut help needed!!!!!!

cut help needed!!!!! -------------------------------------------------------------------------------- /home/documents/files/scooter17.dat I am trying to cut out everything upto scooter17.dat so that it will only print out the scooter17.dat any ideas? great advices will be greatly... (1 Reply)
Discussion started by: scooter17
1 Replies
Login or Register to Ask a Question