complete file name displayed instead of extension


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting complete file name displayed instead of extension
# 1  
Old 05-18-2009
Question complete file name displayed instead of extension

I am running my script from "/abc/" this path and it has no ".csv files" but has a ".txt" files namely temp1.txt
My script goes as below, wherein it is suppose to find files with *.txt extension and *.csv extension in another path namely "/abc/xyz/":
Code:
#!/bin/ksh
PATH1="/abc/xyz/"
value="*.csv *.txt"
for THISTEMPLATE in $value
do
   THISTEMPLATE=`echo "$THISTEMPLATE" | tr "%" "?"`
  echo "thistemp = $THISTEMPLATE"
  for OLDFILE in `find $PATH1 -name "$THISTEMPLATE" -type f`
  do
    echo "oldfile= $OLDFILE"
   done
done

>OUTPUT:
thistemp = *.csv
thistemp = temp1.txt
But if you see the output the variable contains the filename "temp1.txt" instead of just "*.txt", how can i modify the script so that
the variable THISTEMPLATE takes only *.txt instead of the whole filename.

Last edited by Franklin52; 05-18-2009 at 03:57 PM.. Reason: adding code tags
# 2  
Old 05-18-2009
Change this line:

Code:
for THISTEMPLATE in $value

with:

Code:
ls $value 2>/dev/null | while read THISTEMPLATE

# 3  
Old 05-19-2009
Data solution did not help

after changing,
the output is just displaying this Smilie
OUTPUT
thistemp = temp1.txt

can someone please help
# 4  
Old 05-19-2009
Code:
 
for THISTEMPLATE in "*.txt" "*.csv"

# 5  
Old 05-19-2009
Question

But that would not make it dynamic.

I dont want to hardcode the value in the for statement..

Is there any other way ?
# 6  
Old 05-19-2009
Quote:
Originally Posted by wolverine999
after changing,
the output is just displaying this Smilie
OUTPUT
thistemp = temp1.txt

can someone please help
From your first post:
Quote:
Originally Posted by wolverine999
it has no ".csv files" but has a ".txt" files namely temp1.txt
What are you expect if you have only one .txt file?
# 7  
Old 05-20-2009
temp1.txt is present in /abc/ , this is the place from where i am running the script.

but i would like to find *.txt files in another location /abc/xyz/

The output should display all the ".csv" and ".txt" files in present in /abc/xyz/, instead of /abc/
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Colorful message is displayed in the terminal but not in the log file

Is there any way to print the colorful message in the terminal (which is the output of a simulation) to the log file with the same color. The colorful message at the terminal is obtained by the following codes: /////////////codes start here/////////////////////////////////////// ... (5 Replies)
Discussion started by: babunp114525
5 Replies

2. UNIX for Beginners Questions & Answers

Tee doesn't write all displayed data into text file

"Debain 9 - LXDE" I execute follow line in the bash terminal: /ts3/server/ts3server_startscript.sh start createinifile=1 | tee -a /ts3/server/key.txt The displayed output looks like follow: My key.txt file looks like follow: How can i save the whole displayed text in my file? Why does... (5 Replies)
Discussion started by: int3g3r
5 Replies

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

4. UNIX for Advanced & Expert Users

Pound symbol is not displayed in Linux file

Hi All, I am trying to copy a test from database into a file, basically that is what our application do. We will process all values and store it in a Linux file. When i look the database I am seeing as below spend (£000's) but after processing and stored to a file , i am seeing as... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

5. Shell Programming and Scripting

In Outlook spooled file data is not getting displayed properly

I am fetching a database table in spool file and send that details as a email. The Spooled file content is properly being displayed in UNIX. See Example below : ID|FILENAME |ABCDEF_DT |PROCESSED_DT |STATUS... (4 Replies)
Discussion started by: Ravi_007
4 Replies

6. Shell Programming and Scripting

Unix Scripting : Sort a Portion of a File and not the complete file

Need to sort a portion of a file in a Alphabetical Order. Example : The user adam is not sorted and the user should get sorted. I don't want the complete file to get sorted. Currently All_users.txt contains the following lines. ############## # ARS USERS ############## mike, Mike... (6 Replies)
Discussion started by: evrurs
6 Replies

7. Shell Programming and Scripting

How to find complete file names in UNIX if i know only extention of file

Suppose I have a file which contains other file names with some extention . text file containt gdsds sd8ef g/f/temp_temp.sum yyeta t/unix.sum ghfp hrwer h/y/test.text.dat if then.... I want to get the complete file names, like for above file I should get output as temp_temp.sum... (4 Replies)
Discussion started by: panchal
4 Replies

8. Shell Programming and Scripting

Output file not displayed in the proper format

Hi am using uuencode fro attaching one report which is nothing but sql query output. But when i receive the report through attachement and when it is opened the report is not displayed in proper format. Means if the sql query has 100 rows the mail attachment report displays the report in 2... (2 Replies)
Discussion started by: weknowd
2 Replies

9. UNIX for Dummies Questions & Answers

BASH complete-filename & menu-complete together

Hi, Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab? Right now this is what I have in my .bashrc: bind "set show-all-if-ambiguous on" bind \\C-o:menu-complete This allows... (0 Replies)
Discussion started by: Mithu
0 Replies

10. UNIX for Dummies Questions & Answers

perl - file reading - last line not displayed

Hi, Here is something that am trying with perl #! /opt/third-party/bin/perl open(fh, "s") || die "unable to open the file <small>"; @ch = (); $i = 0; while( $content = <fh> ) { if( $i <= 5 ) { push(@ch, $content); $i++; } else { $i = 1; foreach(@ch) { (8 Replies)
Discussion started by: matrixmadhan
8 Replies
Login or Register to Ask a Question