Need to extract name from input


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to extract name from input
# 1  
Old 02-28-2012
Question Need to extract name from input

SmilieHi All,

I have created a common shell scripts which accepts 1 input variable which has the name of the datafile(v3_pcr2ecm_wkly_mainbase_maps_20120228.txt) and this name of the datafile keeps changing.

I need to remove .txt extension and create a new log file as
v3_pcr2ecm_wkly_mainbase_maps_20120228_extract.log

please help me out.

eg:
file="$1" -> the input name changes everytime. if $1=v3_pcr2ecm_wkly_mainbase_maps_20120228.txt
log=$1.log

output log should have name:
v3_pcr2ecm_wkly_mainbase_maps_20120228_extract.log

please helpSmilie
# 2  
Old 02-28-2012
Code:
 
$ file=one.txt
$ logfile=${file%%.*}.log
$ echo $logfile
one.log

# 3  
Old 02-28-2012
MySQL thanks..

THanks a lot for your help itkamaraj.
it worked out. Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Enhance existing script: Extract Multiple variables & Input in an echo string

Hi Experts I need your help to optimize my script to execute better as I have nearly 1M records & the script is taking close to 40 minutes to execute, so would need support on a faster alternative. Input: file {"house":"1024","zip":"2345","city":"asd","country":"zzv"}... (2 Replies)
Discussion started by: nk1984
2 Replies

2. Shell Programming and Scripting

Bash to extract file prefix and from input to use in output

In the bash below which does execute I am trying to extract the contents of ${id} is 1234, as ${id} stores the variable that changes each time. After the path is removed the contents of ${id} are stored in pref, so they can be used in the output. Currently I am not able to extract the 1234 in the... (6 Replies)
Discussion started by: cmccabe
6 Replies

3. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

4. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

5. Shell Programming and Scripting

Extract the lines from input file

This is the sample input file b 05/Jul/2010:07:00:10 a 05/Jul/2010:06:00:10 b 05/Jul/2010:07:00:10 c 05/Jul/2010:07:10:10 d 05/Jul/2010:08:00:10 e 05/Jul/2010:09:00:10 f 05/Jul/2010:10:00:10 h 05/Jul/2010:11:00:10 i 05/Jul/2010:12:00:10 j ... (9 Replies)
Discussion started by: sandy1028
9 Replies

6. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies

7. Shell Programming and Scripting

To extract <P> tags in a custom manner from below mentioned input.

Following is input: <P align="justify" ><FONT size="+1" color="#221E1F">the tiny bundles of hairs that protrude from them. Waves in the fluid of the inner ear stimulate the hair cells. Like the rods and cones in the eye, the hair cells convert this physical stimulation into neural im<FONT... (2 Replies)
Discussion started by: parshant_bvcoe
2 Replies

8. Shell Programming and Scripting

Please help: Extract filtered output from following input

Following is input: <P align="justify" ><FONT size="+1" color="#221E1F">the tiny bundles of hairs that protrude from them. Waves in the fluid of the inner ear stimulate the hair cells. Like the rods and cones in the eye, the hair cells convert this physical stimulation into neural im<FONT... (1 Reply)
Discussion started by: parshant_bvcoe
1 Replies

9. UNIX for Dummies Questions & Answers

extract a part of a path like (input: /etc/exp/home/bin ====> output: exp)

Hi, I need to make some extraction . with the following input to get the right output. input: /etc/exp/home/bin ====> output: exp and input: aex1234 ===> output: ex Thanks for your help, (4 Replies)
Discussion started by: yeclota
4 Replies

10. Shell Programming and Scripting

extract/select pattern from input

Hey, examples of the input (text line): /bla/blMOasdn234.adanif24/blabla.rar /bla/blMOasdn234.adanif24/blabla23124.bin /bla/bla/bla/bla/bla/bla.bin and what I need to do is extract/select only the dir path so the output would be: /bla/blMOasdn234.adanif24/ /bla/blMOasdn234.adanif24/... (4 Replies)
Discussion started by: TehOne
4 Replies
Login or Register to Ask a Question