Command nee to cut the record


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Command nee to cut the record
# 1  
Old 08-28-2008
Command nee to cut the record

I have a file which contains a record like follows

/dir1/dir2/dir3/file.dat

I need command to so that output can be only file.dat
# 2  
Old 08-28-2008
You want the basename command.
# 3  
Old 08-28-2008
i need to eliminate the path from that record and want only the file name
I think cut will be used but I appreciate if get full command with options to be used
# 4  
Old 08-28-2008
U can try basename /dir1/dir2/dir3/file.dat
# 5  
Old 08-28-2008
Hi Rahul



the basename command is not reading the file the in which records are present.



i have a file (say temp) which contains the records in the following format



dir1/dir2/dir2/file.dat

dir1/dir2/dir2/file2.dat

----

-----



so now i need to get only file names that temp file
# 6  
Old 08-28-2008
# 7  
Old 08-28-2008
Please don't double-post. Please continue at https://www.unix.com/unix-dummies-que...#post302230158
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Code snippet to cut XML files based on record length

I want to do FTP an Huge XML file to mainframe server using AIX server Since my file size is huge, i want to split the XML file based on a delimiter , the record delimiter should be set after every 27000 bytes of data and then do the ftp This is done becos the data send to the mainframe must... (1 Reply)
Discussion started by: vishwanath001
1 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. AIX

Record topas command output

How to record output of below command in a text file. topas -P or is there any other command which will do the same thing in AIX. I would like to get a report something similar to below commands. top -b prstat -c (5 Replies)
Discussion started by: NarayanaPrakash
5 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. Shell Programming and Scripting

Record all users' command

Hi experts, .history can record one user's own command history, but my request is, I want to record all users who run commands on that box, and export the commands to a file somewhere, which record the userid, time and full command. Is it possible? I just need for audit, and trace back, if... (3 Replies)
Discussion started by: newoz
3 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. Shell Programming and Scripting

How to copy particular record with cp command

Hi , I have a table of 5 records. I am using FOR condition in this table. Using FOR , I want to copy those particular record into someother file which satisfies the condition. How to use 'cp' command in this situation in UNIX For Ex No Prod Price Bar Code 1 Colgate 23 34564 col 2... (5 Replies)
Discussion started by: devmns
5 Replies

8. Shell Programming and Scripting

awk & cut record separator problem

Hi All, I've got some strange behaviour going on when trying to manipulate a file that contains spaces. My input file looks something like this: xxxxxxxxx,yyyy,sss sss sss,bbbbbbb If I use awk: When running from the command line I get: sss sss sss But when running from a... (7 Replies)
Discussion started by: pondlife
7 Replies

9. Shell Programming and Scripting

Nee help debugging script..plz

I am having problems w/this script. Menu is not comming up to prompt me. I've worked on it for days and still cannot see the problem. Anyone can help, I would appreciate it. Possible problems with syntax and function calls. Thks... TMP=$tapemgr/rpts/tmp # TAPE MANAGER MAIN MENU while : do... (8 Replies)
Discussion started by: gzs553
8 Replies
Login or Register to Ask a Question