Questions concerning basic bash scripting

Good evening,
at the moment we do bash scripting at university, but I seen to encounter some problems in understanding the functionality of bash. I would be very grateful if you guys could help me out with one or another question.
First one:
Task to accomplish: Scripts with three arguments. $1 -> source directory, $2 -> file suffix, $3 -> target directory. Search source directory for all files with suffix $2 and copy them to $3.
I tried to do it, using pipe and xargs, but I am wondering how to pass the filenames found over the pipe.
find $source -name "*.$suffix" | xargs cp [MISSING ARGUMENT] $target
How do I access the data I need to fill in as first argument of cp, or isn't it possible to accomplish the task this way?
Regards,
cg

chaosgeisterchen wrote:find $source -name "*.$suffix" | xargs cp [MISSING ARGUMENT] $target
Almost, you just need the -t flag to cp which basically reverses the order of SOURCE and TARGET in this instance
find $source -name "*.$suffix" | xargs cp -t $target
Also, I suggest you escape the * in your find to prevent bash expanding it. Bash shouldn't expand, find should.
You might like to also use the -iname (as opposed to -name) predicate to find if you don't care about the case of the source files.
Last edited by fukawi2 (2008-06-02 03:13:37)

Similar Messages

  • Scripting Question - Very Basic

    Hello, I'm using the trial version of InDesign and am wondering if because it's the trial version that I can't load custom scripts from Adobe?  I've downloaded and installed a Custom Calendar script [I can see the extracted files in/on my PC] but the app apparently doesn't see it.  Any help you can offer is greatly appreciated.  Thanks, 

    Thank you so much, you were spot on. 
    From: Peter Spier <[email protected]>
    To: Friar5 <[email protected]>
    Sent: Monday, December 12, 2011 3:18 PM
    Subject: Scripting Question - Very Basic
    Re: Scripting Question - Very Basic created by Peter Spier in InDesign - View the full discussion
    Have you put thew script in a location that InDesign uses for scripts? See How to install scripts in InDesign | InDesignSecrets
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4079869#4079869
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4079869#4079869. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in InDesign by email or at Adobe Forums
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • [DONE] Bash scripting. A few questions

    Hi,
    I've created my own custom sleep script as it is described here: https://wiki.archlinux.org/index.php/Sy … stem-sleep and it's already working correctly.
    However I've got a few questions concerning bash scripting since I've never did it before.
    Here the example from the wiki:
    #!/bin/sh
    case $1/$2 in
    pre/*)
    echo "Going to $2..."
    post/*)
    echo "Waking up from $2..."
    esac
    Now what do I need the /*) for in the cases pre and post? What does it do? And why isn't there any *) in the end which would exit the script if none of the above is true?
    Secondly, why does it say case $1/$2 in, but not case $1 in, what is the $2 needed for? E.g. in this script only $1 is used: https://wiki.archlinux.org/index.php/OS … ibernation
    And third question is, if I do really need the double quotes around $1? Does it make any difference?
    Sorry for my incompetence but I'm not a dev and as I already said I've never did any bash scripting...
    Thanks in advance
    best regards
    nuc
    Last edited by nuc (2013-02-07 18:10:56)

    ok, here's my actual code:
    #!/bin/sh
    suspend_osssound()
    /usr/lib/oss/scripts/killprocs.sh
    /usr/sbin/soundoff
    resume_osssound()
    /usr/sbin/soundon
    case "$1" in
    pre)
    suspend_osssound
    post)
    resume_osssound
    *) exit $NA
    esac
    It is the same as the one in the OSS wiki entry, but slightly configured to work under logind and not pm-utils. Of course the new location is /usr/lib/systemd/system-sleep/.
    I'm about to update the wiki with my code, so I'd like to know if there aren't any major mistakes. I tested it and it works but I want to get sure
    PS: Do people actually still use pm-utils for suspending or can I safely remove the previous script from the wiki?
    EDIT: Added double quotes
    Last edited by nuc (2013-01-25 23:42:02)

  • Question concerning sap script

    Hi all experts! I have a question concerning sap script
    First some background information:
    I’ve created a sap script  that is called from a function module and from an executable program,  when I run the executable program the sap script work fine, but when I run the function module, all the variables in the sap script don’t have value
    In the function module the variables are defined in the top include
    I don’t know why these variables don’t take his value from the function module
    Any ideas?
    Thanks in advance.
    Message was edited by: Gerardo hernandez

    I think that sapscript expects its variables to be in the program which calls the fm <b>by default</b>. When you test via SE37 the framework itself is the calling program and it's unlikely that it will have a variable named kunnr-name1.
    To over-ride this default, inside your fm pass the 'options' parameter(type itcpo) to 'open_form' and set the 'tdprogram' value to sy-repid in the function module.
    I have tested this in my own environemnt and initially got the same error as you. When I set the tdprogram variable it started working!

  • 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)

  • Newb bash script

    Well I've had linux for about a year or so now....Well I suppose longer than that but I didn't use it for a while but here I am full time user of Linux for about a year now, wahoo!
    Anyways, I suppose its time to dabble into some coding so I can understand those pesky pkgbuilds when I wanna change them...
    Basically right now I have the linux client Team Fortress 2 dedicated server installed and it has a command to run which starts the script.  I made a script in /usr/bin that I can call on quickly with just 'tf2server' to fire up the server when I want.  It already has the options in that script such as the players and which map to load.
    ./srcds_run -game tf +maxplayers 5 +map
    is basically the line that it calls. What I want to do though is instead of having to go to the folder where it is and running that command with different options when I want to each time I'd like to be able to just do something like...
    tf2server cp_well
    for example, and then it would use well for the map.  I know that in terminal you can type --help on most commands and it will show you usage, so basically my question is....Is there a guide, or someone willing to give an example on how I can accomplish this? I'm assuming it will only take bash and some wildcards of some kind to do.
    Help is appreciated

    SiegeMachine wrote:./srcds_run -game tf +maxplayers 5 +map
    Unless your script is explicitly cd'ing into the directory for 'srcds_run', then attempting to invoke the command found in the current directory is probably not what you want.  If this is the case, I'd either have the script change to the correct directory itself, or ensure the path to srcds_run is in your $PATH and remove the leading "./".  When running a script, the current directory is that which the script was invoked from and not that which the script is located.
    To accept options as in your example is quite simple:
    ./srcds_run -game tf +maxplayers 5 +map $@
    $@ evaluates to the argument(s) specified.  So, assuming the '+map' option takes the name of a map as an argument:
    tf2server cp_well
    Should work fine.  With this you can also specify any additional settings for the server.  E.g.,:
    tf2server cp_well +timelimit 30
    (Note: I know nothing about Team Fortress. '+timelimit' probably doesn't exist; I'm just making things up )
    If you're interested in learning shell scripting, Advanced Bash Scripting (PDF) is an excellent resource.
    Hope this helps.
    Last edited by chpln (2009-12-17 09:54:15)

  • Solaris 11 - run a simple BASH script on computer startup

    I need to have a simple BASH script run on my Solaris 11 machine automatically whenever the computer (re)starts. It should be run with root permissions and after the computer has fully booted. What is the easiest way to do that?
    Thank you
    Dusan

    Hi user9368043
    Yes, that should be right, and be intended this way.
    See /etc/rc3.d/README and the following part from smf(5):
    Legacy Startup Scripts
    Startup programs in the /etc/rc?.d directories are executed
    as part of the corresponding run-level milestone:
    /etc/rcS.d milestone/single-user:default
    /etc/rc2.d milestone/multi-user:default
    /etc/rc3.d milestone/multi-user-server:default
    Your question concerning upgrading to Solaris 11.1:
    In the Gnome menus, you should look for (and start)
    System --> Administration --> Update Manager
    Let it do its work. It will give you a new boot environment, containing Solaris 11.1. Possibly, you have to perform upgrading twice. With "beadm activate", see beadm(1M), you can go back to Solaris 11.0 whenever you want.
    "Local" parts of your zfs root pool, like /usr/local, home directories, /root, and so on, should be in separated file systems, and be mounted outside the root pool before upgrading. They are availlable then from any boot environment, and will not be duplicated. See more in zfs(1M), zpool(1M).
    I strongly recommend upgrading. Solaris 11.1 is great.

  • Sending email using bash script

    Hello:
    I am working on writing a bash script to notify one or more users by email of certain events. Run from the Terminal command line, and having the script "echo" text of (what would be) a form letter with in-line variable expansion (i.e., ${VARIABLE}), all seems to work as anticipated. Eventually, I want cron to launch this shell script, and send an email to an "on-subnet" user (I have postfix enabled on my Mac, and there are multiple local user accounts).
    I found some stuff on the web about sending mail from bash scripts, and so I made a small little test script, that reads like this:
    #!/bin/bash
    VARIABLE[1]="The 12,345 quick brown foxes "
    VARIABLE[2]="jumped over the 67,890 lazy dogs."
    mail -s "a test email" jv << EOF
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EOF
    echo "script completed"
    It worked... almost... It sent a local email to my postfix mail account that read like this:
    This is a test:
    The 12,345 quick brown foxes
    jumped over the 67,890 lazy dogs.
    This is the last line of the test message.
    EOF
    echo "script completed"
    So, I have two questions. First, the easy one (I hope):
    How do I delimit the end of the text, that I want to be the message body of the email, from portions of the script that follow said email text?
    Next question is a little more involved. You know how, in Mail.app, if you go to Mail Preferences>Accounts>Account Information, you can put multiple email addresses, comma-delimited, in the "Email Address" field? So, if a person entered "[email protected], [email protected], [email protected]" in this field, then, even though (s)he may be at home, and using their home ISP's mail server, (s)he could send an email apparently from either their home, work, or school email address. Of course, the mail headers clearly would show it came from and through their home machine and home ISP, but it would be displayed in the recipient's Mail client viewer as having come from one of [email protected], [email protected], or [email protected].
    I'd like to do something similar here, whereby the email (that is being sent to one or more local users' postfix account on my computer) would apparently be sent from "watchdog@localhost" rather than from "jv@localhost" like it seems to do by default. Whatever account the script is run from (or presumbably, whose cron tab is launching the script) is what the "From" address is set to.
    I'd rather not create an additional mail account, because I am using Mac OS X built-in accounts for the postfix mailboxes (I don't want to have to maintain a plaintext username:password file in postfix, and I don't want to create an additional user account on the computer).
    So, is there a way to specify an alternate "From" username when invoking the mail -s ${SUBJECT} ${RECIPIENT} command in a bash script? Or is there a different, alternate mail command that will let me do so? (please include a description of syntax and how I'd package the above message text for the alternate method).
    Thanks in advance, all!

    Hi j.v.,
    The > after EOF is just a typo (or may be added by the Discussion ?) and you must delete it; other > are prompts from the interactive shell. Andy's post shows an interactive use of shell, not a shell script (note the shell prompt % in front of the commands). A typical use of here document may look like
    command <<ENDOFDATA
    ENDOFDATA
    There must be no spaces before and after ENDOFDATA. The word ENDOFDATA can be EOF or any other string which is guaranteed not to appear in the text (the .... in the example above).
    You can modify the From: header by using sendmail command (postfix has it as a compatibility interface):
    /usr/sbin/sendmail -t <<EndOfMessage
    Subject: test mail
    To: jv
    From: watchdog
    This is a test:
    ${VARIABLE[1]}
    ${VARIABLE[2]}
    This is the last line of the test message.
    EndOfMessage
    There must be a blank line between the headers and the mail body.
    I assume that you send these mails only to users on your local Mac. Please do not send mails to remote users by using the sendmail command unless you know what you are doing completely.
    PowerMac G4   Mac OS X (10.4.5)  

  • Can't get conky-cli and bash scripts to both display in dwm statusbar!

    I'm trying to configure my dwm status bar to display some simple information using conky-cli and bash scripts. At first I tried just letting conky run the bash scripts (for network and volume state), but this increased my cpu usage by about 5%, which is significant considering I normally have 1-3% usage when idle. Also, I wanted to keep conky because it makes the display of certain information easy, such as cpu & RAM usage.
    The problem is I'm having trouble getting both to display side by side. Here are the relevant parts of my .xinitrc:
    network(){
    iwconfig wlan0 2>&1 | grep -q no\ wireless\ extensions\. && {
    echo wired
    exit 0
    essid=`iwconfig wlan0 | awk -F '"' '/ESSID/ {print $2}'`
    stngth=`iwconfig wlan0 | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1`
    bars=`expr $stngth / 10`
    case $bars in
    0) bar='[-------]' ;;
    1) bar='[#------]' ;;
    2) bar='[##-----]' ;;
    3) bar='[###----]' ;;
    4) bar='[####---]' ;;
    5) bar='[#####--]' ;;
    6) bar='[######-]' ;;
    7) bar='[#######]' ;;
    *) bar='[--!!!--]' ;;
    esac
    echo $essid$bar
    exit 0
    volume(){
    vol=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print "MM" } else { print $2 }}' | head -n 1)
    echo Vol: $vol%
    exit 0
    conky | while true; read line; do xsetroot -name "`$line` `volume` `network` `date '+%a %m-%d-%Y %I:%M%p'`"; done &
    exec dwm
    (let me know if it would help to post any other files)
    For some reason when I run this I only get the network/volume scripts and date running, updating every second (I think). The conky line just doesn't show up. I don't know what could be wrong, since I didn't see any error messages.
    An even better solution would be to just have shell scripts to display CPU and MEM usage. I have a dual-core cpu, cpu0 and cpu1. I'd like to see both percentages if possible, or at least a percentage that is an accurate average of the two or something. In conky-cli I have something that shows:
    cpu0/1: xx% xx%
    Also, seeing RAM usage would help a lot. In conky it shows:
    mem: xx% (xxxMB)
    These are the ways I would like to have bash scripts show them, if possible, but I have zero skill in bash programming. I made this an option in case it's easier/cleaner/less resource hungry than a conky solution. Personally, if they're about the same in these aspects, I would prefer something with conky and the shell scripts because conky is so extensible, yet it's only flaw is executing scripts with minimal resource usage.
    Help?

    Thanks. I was thinking of using load average to save a few characters, but I didn't quite understand the numbers. I'll try that once I get to my Linux box, but could you please explain or post a link to something that explains load average (what's low, high, normal, etc.)?
    EDIT: I found a website that explains loadavg. I now have my dwm status bar displaying it perfectly (yay!). Now I just need to add a few more things like battery status, etc. and I might be done. I'll probably post here if I have more questions, though.
    Thanks for your help!
    Last edited by Allamgir (2009-07-18 14:41:11)

  • Using Bash script to edit config file

    This is a really simple question, but given that I'm just learning Bash scripting and having this solved now would be really illustrative for me, I would really thank some help here.
    I'm using uzbl, and running Tor+Polipo. So, as you will see below in the tail of the config file, there is a line to redirect the requests of uzbl through Polipo.
    # === Post-load misc commands ================================================
    sync_spawn_exec @scripts_dir/load_cookies.sh
    sync_spawn_exec @scripts_dir/load_cookies.sh @data_home/uzbl/session-cookies.txt
    # Set the "home" page.
    #set uri = https://duckduckgo.com
    # Local polipo proxy
    set proxy_url = http://127.0.0.1:8123
    # vim: set fdm=syntax:
    What I want to accomplish is to comment in/out that line with a key shortcut on Awesome. I've thought of doing 2 scripts to do so and using 2 differente key shortcuts, but I want to "toggle" the proxy redirection with only 1 shortcut. To do so, I suppose that the script should go something like:
    if
    tool 'set proxy_url = http://127.0.0.1:8123' config_file
    then
    tool '#set proxy_url = http://127.0.0.1:8123' config_file
    else
    if
    tool '#set proxy_url = http://127.0.0.1:8123' config_file
    then
    tool 'set proxy_url = http://127.0.0.1:8123' config_file
    fi
    fi
    I know little about sed, but I think is the tool for this job. The most intriging part to me is to ask sed to print the regular expression when it finds it in the config file, and use that as an input in the conditional statement.
    Well, this is a mess I have done here. Hope there is a simple answer to this.
    Thanks in advance.-

    You can do this with a single sed command:
    sed -i 's/^#set proxy_url/set proxy_url/;
    t end;
    s/^set proxy_url/#set proxy_url/;
    : end' config_file
    This edits the file in-place (-i) and first tries to replace the commented with the uncommented line. If that suceeds, sed jumps to the "end" label. If not, it tries to replace the uncommented with the commented line. Thus you don't have to include any logic about the current state: if the first substitution succeeds, the line was obviously commented, if not, it was uncommented, and the second substitution should succeed.
    Note that my knowledge of sed is very limited. There might be a simpler way to do this.
    EDIT: For the sake of example, here's how to do the same in bash using regular expressions. Note how this script needs to use a temporary file to simulate in-place editing, how it needs to process the file line by line manually, etc. All things that sed does out of the box...
    #!/bin/bash
    tmp=test.conf.tmp
    echo -n "" > "$tmp"
    while read line; do
    if [[ "$line" =~ ^#set\ proxy ]]; then
    echo "${line/\#/}" >> "$tmp"
    elif [[ "$line" =~ ^set\ proxy ]]; then
    echo "#$line" >> "$tmp"
    else
    echo "$line" >> "$tmp"
    fi
    done < test.conf
    mv test.conf.tmp test.conf
    To answer your original question, the line
    if [[ "$line" =~ ^#set\ proxy ]]; then
    reads: if the line begins with a "#", followed by "set proxy", then...
    Last edited by hbekel (2011-03-20 10:40:16)

  • Bash script to insert item in a alphabetical list

    I would like to use a bash script to insert a new "source" file into a list of sources which occurs within another file.
    The file in question is quite long and contains many other things. However the list of sources abides by the format below.
    [snip]
    SOURCES = \
    _add_datasource_.m \
    _add_line_series_.m \
    ylabel.m \
    ylim.m \
    zlabel.m \
    zlim.m
    [snip]
    How might I insert a new source file in alphabetical order. I'm assuming there is a fairly simple script to do such.
    TiA

    #!/usr/bin/env bash
    if [[ $# != 1 ]]; then
    echo 1>&2 "Usage: ${0##*/} fileto_insert_inSOURCE"
    exit 1
    fi
    MAKEFILE=Makefile.in
    TMP=/tmp/tmp.$$
    awk -v new="$1" '
    /^SOURCES =/ { in_src = 1 }
    in_src && ! done && $1 > new {
    # New file goes here
    printf(" %s \
    ", new)
    in_src = 0
    done = 1
    in_src && ! done && ! /\$/ {
    # New file must go after the last entry.
    # Put  on old last entry.
    printf("%s \
    ", $0)
    # replace current $0 with the new file.
    $0 = sprintf(" %s
    ", new)
    done = 1
    ! /\$/ { in_src = 0 } # NOT in SOURCE
    { print } # print current line
    ' $MAKEFILE >$TMP
    mv $TMP $MAKEFILE

  • Bash script to trim all filenames with special characters recursively?

    Hi,
    I have a 30 GB directory full of data I recovered from a friend's laptop after her Windows XP crashed. I'd like to burn that data, but I can't, because many of the filenames contain weird characters (spaces, accents, things even worse that my XTerm displays as inverted question marks). So, mkisofs exits with an error.
    I'd like to clean that mess up, but it would take months to do that manually. Well, I only know a very little Bash, but I think this problem is already too heavy for my modest knowledge. Here's the problem:
    - check the contents of directory ~/backup recursively
    - find files whose filenames contain characters other than [A-Za-z0-9] and then maybe "-" and "_" and ".".
    - replace these characters either by an "_" or just erase them
    Now how would I translate that into a little Bash script?
    Cheers...

    Heyyyyy... nice idea

  • Bash script to dumpstream many files simultaneously with mplayer

    hi guys
    i have a problem which i´m sure can be solved with the power of bash scripting
    unfortunately i´m no bash scripting guru and all my experiments failed so far
    the problem:
    i have a file in which are links(streaminglinks)
    mplayer offers the funtion to dump such a stream with simply issuing
    mplayer -dumpstream mms://path/to/video -dumpfile video1
    for example.
    now i want mplayer to download this streams specified in the links-file automatically.
    basically all it required is a bash script which goes through the link file and generates a command like mplay -dumpstream <link> -dumpfile video<n>
    (where n is the nth link) and execute it.maybe there a even simpler solutions
    well since i´m not that experienced with bashscripting i can´t solve that problem at my self....
    i´m grateful for any help

    hey guys
    thx for the two scripts.
    my approach was nearly the same as your´s kraluz with the difference that it doesn´t work
    but they both have a little blemish
    they download the files sequentially not simultaneously
    how could that be realised
    thx in advance

  • Bash script: Loop command,

    Hi all,
    I need a bit of help looping a command on a bash script,
    please see below the command I need to loop:
    ffmpeg -s 2720x1024 -r 25 -f x11grab -i :0.0 -acodec libmp3lame -ab 128k -vcodec mpeg4 -sameq -y -t 60 /media/z/.cam/screen/screen_`date +%F_%T`.avi
    So basically I record my screen for a period of 1 minutes and the process once done need to restart.
    I have search on how to loop the command but I must admit it seem rather complicated, so for the time being I added && at the end and paste the command a lot...
    Any help would be appreciated,
    Many thanks,
    Regards

    sweetthdevil wrote:ffmpeg -s 2720x1024 -r 25 -f x11grab -i :0.0 -acodec libmp3lame -ab 128k -vcodec mpeg4 -sameq -y -t 60 /media/z/.cam/screen/screen_`date +%F_%T`.avi
    I recommend using the FFmpeg commands shown here:
    How to do Proper Screencasts on Linux Using FFmpeg
    It's a well-written guide and the author, verb3k, keeps it up to date which is essential when working with FFmpeg.  Compared to your command the output will probably look better. The command from the guide will also probably be closer to your requested frame rate because the lossless output should be easier for the CPU to deal with and the command utilizes the -threads option.  Lastly, the -sameq option should not be used. The documentation is misleading and should read something like, "use same quantizer as source" instead of "use same video quality as source". Use of the same quantizer does not mean same quality, and this option especially should not be used when the source and output formats do not share the same quantizer scale.
    Last edited by DrZaius (2011-03-27 00:31:46)

  • Parsing sh/bash scripts: Get all executable/function calls out of it

    I'm doing some analysing of some code written in bash.
    Now I must know all the "things" that are executed (or can be executed) from inside the script, without executing the script.
    So basically the script must be parsed and all the occurrences of executions of programs and sh functions must be listed.
    Does anyone know if there is a tool/script for this somewhere?
    Thanks.
    Last edited by Dieter@be (2008-11-08 15:12:07)

    First you should know that it's impossible to get a guaranteed-correct answer without executing the script. Scripts can call programs/functions whose names are found/generated at runtime. The most common example is opening a text file using the program whose name is stored in $EDITOR.
    That said, you can get an approximation by writing a parser. Parsers are hard. Smart programmers use a parser generator like bison or ANTLR to abstract away much of the complexity, but it's still sort of a pain in the butt the first time or two.
    If you don't want to write a parser, a very approximate answer can be found by splitting each line by whitespace and returning the first word. Then finding other places commands can hide, like after semicolons, backticks, "$(", etc, but not when quoted. At this point, you will have written a very shoddy parser and taken longer at it than you would have if you'd bothered to learn bison or ANTLR.
    Last edited by skymt (2008-11-08 15:34:36)

Maybe you are looking for