Bash command question

I volunteered to download my school's entire website, as the current host is going into liquidation and they can't get a copy of the database. So I downloaded the whole thing with wget. Now, the problem is that many (several hundred) of the files have names like "featureDetails.asp?featureID=2", which is fine on a JFS partition, but can't be on a FAT partition.
So, my question is, how do I replace all "?"s, and "="s with "-"?
PS: I really have no idea where to post this, so picked this board at random

fwojciec wrote:
If it's just a matter of renaming the files then you can use something line this:
for i in *; do j=$(echo "$i" | sed 's/?/-/g;s/=/-/g'); mv "$i" "$j"; done
This will rename all files in the current directory.
EDIT:
or something like this would work as well:
for i in *; do j=$(echo "$i" | sed 's/[?=]/-/g'); echo "$i" "$j"; done
These certainly work, and for small jobs they are reasonable, but they are both very inefficient because a new process is forked for every file to be renamed.  Instead consider this:
for i in *; do mv "$i" "${i//\?/-/}" ; done
This syntax is documented in the "Parameter Expansion" portion of the bash(1) manpage.

Similar Messages

  • How do I run a snmpwalk/any bash command as a Linux/Unix command (2 state monitor) on a Isilon storage device

    Is there a way that I can run a snmpwalk / isi devices (to find the status of the disk drives in islon) / any Linux bash command using a 2 state monitor Unix/Linux shell command and target a storage device (Isilon in my case) and not target a Unix/Linux
    machine. I tried creating one and it complained saying,
    Is there a way I could run a bash command in my isilon storage and use the ouput to determine the state of the monitor? Please let me know
    Hari V

    For Unix/Linux shell command in Operation Manager to monitor 2 state, you can refer to below link
    http://contoso.se/blog/?p=2680
    http://stefanroth.net/2012/10/21/scom-2012-linux-two-state-monitor-with-script-in-script/
    http://operatingquadrant.com/2012/02/01/opsmgr-2012-unixlinux-authoring-templates-more-information-on-the-shell-command-templates/#more-746
    Please remember, if you see a post that helped you please click (Vote As Helpful" and if it answered your question, please click (Mark As Answer).

  • Bash commands not working after upgrade to Lion

    After upgrade, many BASH commands not working. For example, such a fundamental thing as "ls". 
    iMac20:bin a$ ls
    Launch of "ls" failed: the PowerPC architecture is no longer supported.
    What does it have to do with PowerPC? My computer is 2.66 GHz Inter Core Duo

    Linc,
    iMac20:~ a$ which ls
    /sw/bin/ls
    Also, I managed to look (using tcsh's ls-F command) into the contents of /usr/. Here's what I see there:
    [iMac20:/bin] a% ls-F
    [*          csh*        echo*       ksh*        mkdir*      rcp*        stty*       wait4path*
    bash*       date*       ed*         launchctl*  mv*         rm*         sync*       zsh*
    cat*        dd*         expr*       link*       pax*        rmdir*      tcsh*      
    chmod*      df*         hostname*   ln*         ps*         sh*         test*      
    cp*         domainname* kill*       ls*         pwd*        sleep*      unlink*    

  • Bash command doesn't work after update

    I just ran pacman -Syu as normal, but some got many errors like below:
    ( 3/11) upgrading binutils
    error: command failed to execute correctly
    and every package except kernel-headers got a error message like that. and then i found most of my bash command doesn't work any more, just like ls and vim. However, some others like pwd and cd still work correctly.
    Any one any ideal?
    Last edited by ranjiao (2009-11-12 13:26:01)

    ranjiao wrote:I removed /lib64 and make a soft link from /lib64 to /lib, as Matlab09 requires a /lib64 containing crt libs.
    is this the cause?
    Yes.
    I've done that before and got into the same problem when updating glibc, the lesson here, don't mess with the default directory structure.

  • Where can I find the LOG file for bash/command history typed into Terminal?

    Where can I find the LOG file for bash/command history typed into Terminal?
    For 2 weeks ago I was searching for a log file on my server. Somehow I opend a file where I could see a list of all bash-commands I had ever entered into OSX Terminal.
    Now I need this file.. but cant find it.
    What is the official location for this LOG file?
    Thank you so much for helping.

    cat .bash_history

  • BASH Command.

    How can i use BASH commands to get files Added on a certain month?
    (I can use only date,ls,cut,awk,sed).
    please help if anybody know...

    (I can use only date,ls,cut,awk,sed).
    Pretty restrictive bash script  If that's the only commands you can use.  What's putting on these restrictions?
    Does it have to be a bash script?  Or are you just want something to produce those results?  Because the system's find (command+f) or utilities like Find any File can do this.  Just look for a mod date within a range.
    For bash do a google search for something like "os x bash to get mod date" for script suggestions.

  • Accessing Bash Command on Lion OS X.

    Hello Apple Forum Community.  Can anyone help me to understand how you access Bash in Lion (through which Utilities)?  If you are not a professional programmer or developer, is Bash command still worthy of being educated about on your Mac?  A website was describing a Bash command prompt for UNIX passwords; hence, could using Bash to generate and/or organize your passwords be your best bet?  Should we really trust 'random password generator' websites to create UNIX passwords, or are we simply wasting our time if we are really not creating the proper password for our Lion OS X. 
    What other functions can Bash be useful for?  Are there a few simple ways to know and/or get into Bash (to know a few advantageous command prompts) for the general Mac user.  Are any Bash commands different for OS X Lion, or are there new ones as well? Thanks.

    Open Applications->Utilities->Terminal.
    I believe the default shell for at least the last few releases is bash, so you'll get straight to it (though I have mine set to tcsh). If not, just type /bin/bash to start a bash shell.
    Random password generator sites are fine  - all they do is generate a random sequence of characters. However, you're probably going to have to write that password down to remember it, which makes it less secure. Better to come up with a sequence that has some mnemonic meaning to you, that contains uppercase and lowercase letters, numbers and other characters, and is at least eight characters long.
    I doubt there's any need for the "general Mac user" to be using a shell, but if you are interested in programming or getting to know how the OS works "under the hood", then it's worth learning about. There are any number of good resources on the web about UNIX shells.

  • Bash command not working

    After an update from leopard to lion my bash command clear does not work.
    If I open terminal and type clear this happens...
    Last login: Wed Jul  4 19:07:27 on ttys000
    You have new mail.
    pancake:~ machinename$ clear
    Launch of "clear" failed: the PowerPC architecture is no longer supported.
    pancake:~ machinename$
    I have tried to copy a copy of the terminal app from another functioning machine running lion, but when it runns on the upgraded machine the result is the same.
    How can I fix this?

    Sorry I better correct some of the info.
    My bash command clear does not work.
    If I open terminal and type clear this happens...
    The machine was bought with Lion preinstalled and the Migration Assistant was use to transfer everything for a user from a Leopard machine.
    Last login: Wed Jul  4 19:07:27 on ttys000
    You have new mail.
    pancake:~ username$ clear
    Launch of "clear" failed: the PowerPC architecture is no longer supported.
    pancake:~ username$
    When attempting to delete the terminal program on the system it is prevented with the message:
    “Terminal” can’t be modified or deleted because it’s required by Mac OS X.
    I then copied a terminal program from another Lion machine but it shows the same message for the command Clear on this machine, but not the machine it was copied from.
    Any ideas is greatly appreciated...

  • Executing a bash command from Java

    I want to execute a bash command from within a Java application on the server. I know how to do simple commands, but this command is killing me. I get nothing back when I send it.
    p = Runtime.getRuntime().exec(new String[]{"ps","-ef","","grep","evolution"});
    There is also another part where I want the results piped to awk and fetch out the pids. BUt with this not working the rest is a waste for now.
    Robbie

    evgeni00 wrote:
    Thank you for assuming the posters' stupidity.I can only see the information that you provide. You didn't say you tried the recommendations.
    I read the article and I tried the things he/she is proposing, also the error stream, guess what it outputs: nothing.Maybe you did it wrong. If you didn't do it wrong, then that program you're invoking is poorly written, because it dies in error without producing any error messages.
    And I also searched for the exitValue 138, but didn't get much further than that its some system specific value. If you know where I can find more information, I would appreciate if you let me know about it. As jschell pointed out it's probably app specific. You can search the source code and/or documentation of that program to see if they say what 138 means.
    Apart from that -- it seems that environment and run directory issues can trip this up. Try checking that stuff out. Maybe your program expects something on the executable PATH that isn't there. Or maybe you're not running it in the working directory that you think you are.

  • How to use 'bash' command in java?

    Hi,
    I am using Linux operating system
    when i run the following code, 'test.sh' not started
    ================================================================
    String cmd = "bash \"/home/kulandaivelu/Desktop/works/other's works/test.sh\"";
    Runtime.getRuntime().exec(cmd).waitFor();
    ================================================================
    but it started when i use same command(bash "/home/kulandaivelu/Desktop/works/other's works/test.sh") in terminal
    anyone let me know what mistake i made in the code piece..
    Thanks in Advance
    Kulandaivelu

    Hi,
    thanks a lot..
    I used the following code.. it worked well..
    ===============================================================
    String cmd[] = {"bash","/home/kulandaivelu/Desktop/works other's/test.sh"};
    Runtime.getRuntime().exec(cmd).waitFor();
    ===============================================================
    Thanks a lot again..

  • How place an LD_PRELOAD bash command into a .desktop file (LXDE)

    To enable video in Skype with my webcam I must launch skype the following way:
    LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype
    To get that command done from my LXDE menu I tried to edit the skype.desktop file and place that line after the "Exec" desktop spec. It does not work, in quotes or not, nor with a full pathname to skype.
    How can I force my desktop entry to run the command above?

    bash -c "LD_PRELOAD=... skype" should work too, for example.

  • [SOLVED] Best place to execute a single bash command at startup?

    Hello everyone,
         I have a very simple problem, but I cannot find a simple solution!  I am trying to use the solarized color scheme with the URxvt terminal. I added all of the color definitions to ~/.Xresources, but when I try to use URxvt after rebooting, it is pink! Apparently this is because ~/.Xresources is not loaded automatically, it must be done manually with the command
    xrdb -merge ~/.Xresources
    Indeed, URxvt is pink before running this command but looks how I expect afterward. My problem has become: Where can I put this single command so that I don't have to type it every time I log in? I am using openbox and LXDE, so I tried putting it in ~/.config/openbox/autostart, like this:
    #! /bin/sh
    xrdb -merge ~/.Xresources &
    I set the executable bit and rebooted, but this doesn't help. Neither does renaming the script "autostart.sh". I also tried putting this command in: ~/.xinitrc, ~/.xsession, /etc/xdg/openbox/autostart, and .bashrc, none of which worked.
    It seems that I am missing something. I am confused and very annoyed that there isn't an obvious place to put this simple command!
    Last edited by ubeatlenine (2014-06-20 17:50:56)

    ubeatlenine wrote:
    runical wrote:What I meant with 'How do you start your WM' was do you start your graphical enviornment from the commandline using startx or do you start using a display manager? This means: do you log in in a terminal and type 'startx' or do you get a nice fancy graphical login screen?
    I get a graphical login, which I take it means that I am using a display manager (which I believe in my case is LXDM). Putting everything into ~/.Xdefaults has technically resolved the issue, thanks to Head_on_a_Stick for their suggestion! However, there is still one thing I would like to resolve. When I login and try to launch URxvt for the first time, I get a pink window in the default geometry. When I launch it a second time, everything works (I get solarized colors and my specified geom.)  Why does this happen? Is there any way to get urxvt to work the way I want the first time?
    If it is indeed LXDM you use, ~./xinitrc is not sourced, so putting the command there should have no effect. As ANOKNUSA said, this shouldn't be a question you answer with 'I think'. You set it up (DMs don't automagically appear or work without intervention), so you are supposed to know. If you don't know, it can mean that you are forgetfull, don't pay attention to your system (trust me, not a good strategy) or you don't use Arch. In the last case you'll have to go to the relevant forum as this forum is Arch support only.
    As for your question about getting urxtv to work the first time, you should look into the logs/error messages generated by urxvt. Maybe you can find something there as there is not much to go on here. I still can't figure out why the first config didn't work, so maybe the problems are related.

  • Unix command question on TAB content

    We found the following ABAP statemenet
    DATA: our_unix_path_and_file_name(64) TYPE c,
               v_unixcmd(255) TYPE c,
               result(255) TYPE c OCCURS 100 WITH HEADER LINE.
    CONCATENATE 'ls -al' our_unix_path_and_file_name INTO v_unixcmd SEPARATED BY space.
    CALL 'SYSTEM' ID 'COMMAND' FIELD v_unixcmd
                    ID 'TAB'     FIELD result-*sys*.
    The question is: is result an internal table? if it's an internal table, then why it's defined as type c?  And also what is included in this result after calling this UNIX command? it will list all the file content?
    Thanks and we will give you reward points!

    Hi,
    The result you'll get is a list of files and attributes from a directory and it will be placed in an internal table.
    Regards,
    Nicolas.

  • Bash command in title?

    how do i put the command in my title? i'm playing around with $BASH_COMMAND but cant get it to work. here's the relevant section i have now in my bashrc:
    PROMPT_COMMAND='echo -ne "\033]0;${USER}: ${PWD/$HOME/~}\007"'
    thanks for any and all help.

    Hi,
    thanks a lot..
    I used the following code.. it worked well..
    ===============================================================
    String cmd[] = {"bash","/home/kulandaivelu/Desktop/works other's/test.sh"};
    Runtime.getRuntime().exec(cmd).waitFor();
    ===============================================================
    Thanks a lot again..

  • Learning how to bash script, questions.

    Hello everyone,
    So I'm learning how to Bash script so I can improve my AUR packages, and also make some scripts for my personal use.
    I've been working on a basic script that completely cleans your kernel source tree while saving your config file.
    I was wondering if this is good and up to today's standards (Meaning checking existence of files, and checking return status for previous command):
    #!/bin/bash
    mv .config config
    if [ -e "config" ] ; then
    echo "Configuration has been backed up successfully."
    else
    echo "Error renaming, quitting program."
    exit
    fi
    echo "Cleaning your kernel source tree!"
    make distclean
    if [ $? -eq 0 ]; then
    echo "Your kernel source tree was clean successfully."
    else
    echo "Error cleaning your kernel source."
    fi
    mv config .config
    if [ -e ".config" ] ; then
    echo "Configuration has been installed successfully."
    else
    echo "Error renaming, quitting program."
    exit
    fi

    What happens if you accidentally run it in your home directory? You probably don't want to be moving your .config folder around like this, even if it doesn't get hurt. Also, what happens if there's a pre-existing "config" file or folder? You should probably inform the user to deal with it, and bail out.
    I would also consider using more verbosity, eg in the calls to "mv", and make the echo statements more descriptive and maybe use some colour.
    In summary, if it were me, a first draft before playing with it more might look a bit like this:
    #!/bin/bash
    set -e
    RED="\[\033[31m\]"
    GREEN="\[033[32m\]"
    BLUE="\[033[34m\]"
    RESET_COLOURS="\[\033[0m\]"
    CONFIG_FILE=".config"
    BACKUP_FILE="config"
    if [[ -f "$CONFIG_FILE" && ! -f "$BACKUP_FILE" ]]; then
    printf "Backing up existing configuration: $BLUE"
    mv -v "$CONFIG_FILE" "$BACKUP_FILE"
    printf "${RESET_COLOURS}\n"
    else
    echo "Existing configuration not found or backup already exists, nothing to do."
    exit
    fi
    printf "Cleaning kernel source tree in $(pwd) ... "
    make distclean
    if [ $? -eq 0 ]; then
    printf "${GREEN}Success!${RESET_COLOURS}\n"
    else
    printf "${RED}Failed!${RESET_COLOURS}\n"
    fi
    if [[ -f "$BACKUP_FILE" && ! -f "$CONFIG_FILE" ]] ; then
    printf "Restoring pre-existing configuration: $BLUE"
    mv -v "$BACKUP_FILE" "$CONFIG_FILE"
    printf "${RESET_COLOURS}\n"
    else
    echo "Backed up configuration not found or pre-existing configuration already there, nothing to do."
    exit
    fi
    Last edited by /dev/zero (2012-01-13 23:03:10)

Maybe you are looking for

  • Error when adding a Title to a Graph in Excel

    I am trying to automate adding a graph to Excel.  The Easy Graph.vi is too simple for what I would like to do. I recorded a macro of what I wanted to do, and then I copied it in LabVIEW basically. My program is erroring out every time I try to modify

  • ITunes 11.0.1 will not sync iPhone 5 and iPad

    ITunes 11.0.1 will not sync either my iPhone 5 or ipad.  After a sync attempt, a box appears which says the device cannot be read or written to.

  • Data migration  and SEPA direct debit structure B2B

    Hi Gurus we are starting SAP roll-out at the company that already has SEPA direct debit B2B process with their customers. This is a recurring B2B process. In their existing Erp system the customers have already  SEPA mandate Reference. We migrated th

  • Upgrading from older OS to latest

    I have 2 older MAC's a G4/700Mhz/OSX 10.3.9 and G5/1.8Ghz/OSX 10.4.11 can I upgrade them to the latest OS and if so what will happen to older programs like CS3 and Quark 7.  Also on the G4 will I be able to install Chrome. Please advise how I can and

  • Mac OS X 10.9.5/CS6 flvデータ不良 OSの影響はあるのでしょうか?

    Mac OS X 10.9.5で.CS6を使用しているのですが. Premiere.Media Encoderどちらもで書き出した FLASH外読み用のflvに原因不明の読み込みエラーが起こってしまいます. (ローカルでvlcでの再生は可能.サーバー上で負荷がかかってしまい.再生に問題あり.) YosemiteのCS6では正常に再生されるので. flvに問題があると思うのですが.OSによってこのような影響は生じるのでしょうか. エラーがでる原因が知りたいです.