To eliminate the created filename


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To eliminate the created filename
# 1  
Old 01-02-2013
To eliminate the created filename

Hi All,

I have two files in the directory
Code:
file1.txt 
file2.txt

I gave ls -m > output.txt command and I got the output as
Code:
file1.txt, file2.txt, output.txt

But my output should be like

Code:
file1.txt, file2.txt

Thanks in advance.

Last edited by radoulov; 01-04-2013 at 08:01 AM.. Reason: Code tags.
# 2  
Old 01-02-2013
Code:
echo $(ls -m) > output.txt

# 3  
Old 01-02-2013
Thank you Smilie
# 4  
Old 01-04-2013
Hi Jotne,

Thanks for your input. But the code creates the filenames with a space accompanied to it, like

Code:
file1.txt, file2.txt, file3.txt

but my output should be like

Code:
file1.txt,file2.txt,file3.txt

Please throw some light on thiz. Thanks in advance.

Last edited by radoulov; 01-04-2013 at 08:01 AM..
# 5  
Old 01-04-2013
Hey,

Try this,

Code:
echo $(ls -m|sed 's/ //g') >output.txt

Cheers,
RangaSmilie
# 6  
Old 01-04-2013
Pls be careful - filenames containing spaces will be distorted. Rather do
Code:
echo $(ls -m|sed 's/, /,/g')

# 7  
Old 01-04-2013
@dubuku_01
In your post #1, you did have space between the filename Smilie
Thanks to RudiC for a good solution..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help to eliminate the records

Hi All, Please help me how to remove the records from the file if it is having more number of fields than the required one, before loading into stage Here is the sample records. File is space delimited one chandu 1121324 CC ( 2 spaces) chandu balu 434657 DD (3 spaces) -- failing due to... (10 Replies)
Discussion started by: bbc17484
10 Replies

2. Shell Programming and Scripting

How to eliminate ^L

Hi, I am trying to create a text file from data retrieved from a query.The data retrieved is having this character '^L' at regular intervals of the data. How can i eliminate this, Please find below the sample data. I tried sed -e "s/\^L//g" to convert it, but with no luck ^LCODE*SERIAL... (11 Replies)
Discussion started by: ramkiran77
11 Replies

3. Shell Programming and Scripting

Compare and eliminate

Could any one help me to compare the date value say at 10th column with sysdate (i.e current date) and if diffrence is more than 50 days then filter them out from the file. The file contain 10000 records. head file 00971502657744 A671FAHP2EW8BG1369172011HRWS contact information ... (6 Replies)
Discussion started by: zooby
6 Replies

4. Shell Programming and Scripting

Filename from splitting files to have the same filename of the original file with counter value

Hi all, I have a list of xml file. I need to split the files to a different files when see the <ko> tag. The list of filename are B20090908.1100-20090908.1200_CDMA=1,NO=2,SITE=3.xml B20090908.1200-20090908.1300_CDMA=1,NO=2,SITE=3.xml B20090908.1300-20090908.1400_CDMA=1,NO=2,SITE=3.xml ... (3 Replies)
Discussion started by: natalie23
3 Replies

5. Shell Programming and Scripting

eliminate pathname from the file name in the o/p

Hi, Im finding some files form a specific path and den writing those files to another file as: find /SYS/admin/data/xml -name '*.xml' -type f ! -newer file1 -print >>out.xml and when im doing cat out.xml im getting like dis: ... (2 Replies)
Discussion started by: ss_ss
2 Replies

6. Shell Programming and Scripting

Eliminate unwanted data

Hi, I am stuck on writing a script that reads a file, retains wanted data but discards unwanted data from a CSV file. This is a sample of my table {not the actual data) ID Color tel_num Name color2 color3 abcdef green 5551212 jj88 red blue acbdfe yellow... (5 Replies)
Discussion started by: t524ube
5 Replies

7. UNIX for Dummies Questions & Answers

How to eliminate wrapped lines

I have a file abc: line 1 line 2 line 3 line 4 And I am successfully e-mailing the file, with this: mail -s "contents of abc" jdoe@email.com <<EOF cat abc EOF But the e-mail shows up looking like this: subject: contents of abc line 1 line 2 line 3 line 4 The carriage returns... (5 Replies)
Discussion started by: tumblez
5 Replies

8. UNIX for Dummies Questions & Answers

Wanted to eliminate numeric part from a filename

Hi, I have a filename called XYZ12345.txt.I just want to eliminate numeric and have only XYZ.txt. How can i do it ? Regards, Sona. (8 Replies)
Discussion started by: Sona
8 Replies

9. Shell Programming and Scripting

How to eliminate extra char?

I was trying to grep a variable with one space in my file: questionlabel=Q1 more job.tex Q1 pear Q1A applie grep -i "$questionlabel\ " job.tex > tmp But I keep getting : Q1 and Q1A both in my tmp Thanks!!!! (4 Replies)
Discussion started by: whatisthis
4 Replies

10. UNIX for Dummies Questions & Answers

boot messages - how to eliminate them

Anyone would know how to get rid off a message that comes up during a boot-up on Solaris? It says that the clusters for this software are not installed. I deleted the software because it was crashing some other stuff but it did not get rid off all the stuff. Yes, I am coming from windows and... (2 Replies)
Discussion started by: softarch
2 Replies
Login or Register to Ask a Question