How to print this out without a extension?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print this out without a extension?
# 1  
Old 01-01-2013
How to print this out without a extension?

i have a file abc.dat that has the below content

abc.dat: -

Code:
123.dat

now,

i want to print/output only the below


Code:
123

from the file content.( see..i want to chop off .dat extension)

kindly advise on this in ksh-

i just want to the flag i should pass to the cat command -

Last edited by joeyg; 01-01-2013 at 08:53 PM.. Reason: Please wrap data and commands with CodeTags
# 2  
Old 01-01-2013
try:
Code:
awk -F"[.]" '{print $1}' 123.dat

also:
Code:
sed 's/[.].*//' 123.dat

also:
Code:
cut -d . -f 1 123.dat

also:
Code:
while read i ; do echo ${i%.*} ; done < 123.dat

There are many other utilities that can return the first field of a record based on a delimiter but I do not think the cat command has any arguments that delimits fields.

Last edited by rdrtx1; 01-01-2013 at 09:12 PM..
# 3  
Old 01-01-2013
Using basename in KSH
Code:
#!/bin/ksh

while read line
do
   basename $line .dat
done < abc.dat

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

How to print full path name along with file extension?

Hi I have a requirement like this: /abc/a/x.txt /abc/a/y.txt /abc/b/x.gz /abc/b/y.txt I need output like this: /abc/a:*.txt /abc/b:*.txt /abc/b:*.gz I have tried find /abc -type f -name "*.*" ||awk -F . '{print $NF}' it is print only extensions without path name. Please... (5 Replies)
Discussion started by: lijjumathew
5 Replies

2. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

3. Solaris

Setting up Solaris 10 to print to a windows print server

Guys, I have a issue that I am trying to rectify please advise. lpstat -t shows scheduler is running printer lext644 disabled since Mon Dec 02 19:48:18 2013. available.I have restarted the printer service and it shows online but the above says disabled. I have a lot of jobs in the print... (1 Reply)
Discussion started by: terrywhitejr
1 Replies

4. UNIX for Dummies Questions & Answers

How to create a print filter that print text & image?

Currently, I have a print filter that takes a text file, that convert it into PCL which then gets to a HP printer. This works. Now I need to embedded a image file within the text file. I'm able to convert the image file into PCL and I can cat both files together to into a single document... (1 Reply)
Discussion started by: chedlee88-1
1 Replies

5. UNIX for Advanced & Expert Users

[Solved] remove all print jobs from a print queue

Hello, Sometimes i need to clear all the jobs of a print queue and it is really annoying to cancel one by one. Is there a way to cancel all print jobs for a specific print queue with a single command instead of cancelling them one by one? My AIX system is 5.3 Thank you for your attention (2 Replies)
Discussion started by: omonoiatis9
2 Replies

6. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

7. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

8. Shell Programming and Scripting

Look for more then one extension.

I am currently scanning a directory with a shell script to look for all files with a .sh extension. I am wondering how to make it look for more then one extension. For example all .sh, .conf, and .sql files? Currently this is what I am doing.... find... (3 Replies)
Discussion started by: LRoberts
3 Replies

9. UNIX for Dummies Questions & Answers

without extension

Hi, I need a help regarding a small requirement. I have a list of C files. I need to put them in a file but without .c extension. say if I have the files as file01.c, file02.c, file03.c etc My file say cfiles should have file01 file02 file03 ... ... etc Appreciate your quick help on... (3 Replies)
Discussion started by: adurga
3 Replies

10. HP-UX

Print Problem in UNIX. Need to know the option to specify the print paper size

Hi, Could any one please let me know what is the option available in UNIX to print by specifying the paper size? We are using Unix11i. I could n't see any option specified in the 'lp' command to print the report by specifying the size of the paper. It would be of great help to me, if... (1 Reply)
Discussion started by: ukarthik
1 Replies
Login or Register to Ask a Question