Sponsored Content
Operating Systems Solaris Get file name in shell scrip loop: bad substitution Post 302519014 by soueric on Monday 2nd of May 2011 08:01:53 PM
Old 05-02-2011
Get file name in shell scrip loop: bad substitution

Hi guys. Good day, morning, afternoon or night, depending on where you live.
I have a script shell in which I am looping on files (absolute path) see code section above.
I always have an error: bad substitution.
Smilie
Is it because my variable file is the index of the loop and not a normal string?
Code:
for file in $home/$input/*.txt
do
    echo ${file##*/}.log
done

I specify that I need to loop on the absolute path, as I do not want to go inside the files folder, as I am running the script from a bin folder and want to stay in there.

Thanks for your help.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bad Substitution

Need Help... I am getting a bad substitution error on my script on a Solaris Server. However the script has been proven to work on HPUX and Solaris servers... #!/usr/bin/sh # # Set the location of the tzupdater.jar file # JAR=/tmp/tzupdater.jar # <<<<< UPDATE THIS LINE... (3 Replies)
Discussion started by: D_Redd74
3 Replies

2. Shell Programming and Scripting

Bad substitution errors in shell script

Hello, I was hoping for a second pair of eyes or a little bit of help figuring out what my error is in a script. I did some searching in the forums and didn't find anything so please forgive me if it a similar problem has been discussed before. My script accepts normal user arguments; however,... (2 Replies)
Discussion started by: Jackinthemox
2 Replies

3. Shell Programming and Scripting

how to combine two files into one file using shell scrip

eg. file 1 has: 4 0 8628380 653253 0 0 0 0 0 0 2 0 8626407 655222 0 0 0 0 0 0 4 0 8633729 647892 0 0 0 0 0 0 5 0 8646253 635367 0 0 0 0 0 0 file 2 has: 4798 48717 11554 5408 56487 14359 6010 58415 15220 5541 41044... (2 Replies)
Discussion started by: netbanker
2 Replies

4. UNIX for Dummies Questions & Answers

bad substitution

#!/bin/bash a1=( win 12,01,02,03,04 ) a2=( pre 04,05,06 ) a3=( msn 06,07,08,09 ) Given the above arrays, I want the script to return/echo the following in a loop; win 12,01,02,03,04 pre 04,05,06,07 msn 06,07,08,09 But I can't get it to do as such. I've tried; (2 Replies)
Discussion started by: Muhammad Rahiz
2 Replies

5. Shell Programming and Scripting

bad substitution error!

Hi All, I'm building a new shell script but i'm facing a problem with one line which is giving "bad substitution" error. Please assist script lines: #!/bin/sh printf "%s: " "Occurrence DATE (YYYYMMDD)"; read DATE shortdate=${DATE#??} o/p: ./test1: bad substitution This command is... (2 Replies)
Discussion started by: Dendany83
2 Replies

6. Shell Programming and Scripting

Why I get bad bad substitution when using eval?

Why I get bad replace when using eval? $ map0=( "0" "0000" "0") $ i=0 $ eval echo \${map$i} 0000 $ a=`eval echo \${map$i}` !!!error happens!!! bash: ${map$i}: bad substitution How to resolve it ? Thanks! (5 Replies)
Discussion started by: 915086731
5 Replies

7. Shell Programming and Scripting

Bad substitution error in shell script

I have script data.sh which has following error. Script Name : data.sh #!/bin/sh infile=$1 len=${#infile} echo $len texfile=${infile:0:$len-4} echo $texfile run command ./data.sh acb.xml I get following error message: (5 Replies)
Discussion started by: man4ish
5 Replies

8. Shell Programming and Scripting

Bad substitution

Cant undestand :) why i have an error on line 2.it is working on my other boxes #!/bin/bash ret=$(echo Q | timeout 5 openssl s_client connect "${1`hostname`}:${2-443}" -ssl3 2> /dev/null) if echo "${ret}" | grep -q 'Protocol.*SSLv3'; then if echo "${ret}" | grep -q 'Cipher.*0000'; then ... (7 Replies)
Discussion started by: kenshinhimura
7 Replies

9. Shell Programming and Scripting

Help with Shell Scrip in Masking particular columns in .csv file or .txt file using shell script

Hello Unix Shell Script Experts, I have a script that would mask the columns in .csv file or .txt file. First the script will untar the .zip files from Archive folder and processes into work folder and finally pushes the masked .csv files into Feed folder. Two parameters are passed ... (5 Replies)
Discussion started by: Mahesh G
5 Replies

10. Shell Programming and Scripting

Bad substitution - ShellCheck says okay

ShellCheck doesn't find any issues with this script. #!/bin/bash # color_meanings: explain meanings of colors used in bash ls eval "$(echo "no:fi:di:ln:pi:so:do:bd:cd:or:mi:su:sg:tw:st:ex" | sed -e 's/:/=/g; s/\;/\n/g')" { IFS=: for i in $LS_COLORS do ... (18 Replies)
Discussion started by: Xubuntu56
18 Replies
RMM(1)								     [nmh-1.5]								    RMM(1)

NAME
rmm - remove messages SYNOPSIS
rmm [+folder] [msgs] [-unlink | -nounlink] [-version] [-help] DESCRIPTION
By default, rmm will remove the specified messages by renaming each of the message files with a site-dependent prefix (usually a comma). Such files will then need to be removed in some manner after a certain amount of time. Many sites arrange for cron to remove these files once a day, so check with your system administrator. Alternately, if you wish for rmm to really remove the files representing these messages, you can use the -unlink switch. But messages removed by this method cannot be later recovered. If you prefer a more sophisticated method of `removing' messages, you can define the rmmproc profile component. For example, you can add a profile component such as rmmproc: /home/foouser/bin/rmm_msgs then instead of simply renaming the message file, rmm will call the named program or script to handle the files that represent the messages to be deleted. Some users of csh prefer the following: alias rmm 'refile +d' where folder `+d' is a folder for deleted messages, and alias mexp 'rm `mhpath +d all`' is used to "expunge" deleted messages. The current message is not changed by rmm, so a next will advance to the next message in the folder as expected. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder rmmproc: Program to delete the message SEE ALSO
refile(1), rmf(1) DEFAULTS
`+folder' defaults to the current folder `msgs' defaults to cur `-nounlink' CONTEXT
If a folder is given, it will become the current folder. BUGS
Since refile uses your rmmproc to delete the message, the rmmproc must NOT call refile without specifying -normmproc, or you will create an infinte loop. MH.6.8 11 June 2012 RMM(1)
All times are GMT -4. The time now is 05:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy