bash

Rename several files in the BASH.

Hi, I would like to rename files numbering: I have a files with '???' format I need to put them in '????'. myfile_100_asd_4 to myfile_0100_asd_4 Thanks Arman. Not so elegant SOLUTION: #/bin/bash snap=`ls -t *_???` c=26 for k in $snap do end=${k} echo mv $k ${k%_*}_0${k##*_}_asd_4 (( c=c-1 )) done This works ...

What are the PowerShell equivalent of Bash's && and || operators?

In Bash I can easily do something like command1 && command2 || command3 which means to run command1 and if command1 succeeds to run command2 and if command1 fails to run command3. What's the equivalent in PowerShell? ...

Passing variable through ssh doesnt work

I'm trying to pass a variable through a ssh connection, like this: working_dir="/home/user/some_dir/" ssh $USER@some_host 'qsub $working_dir/some_file.txt' The connection itself is established, but this code gives me the following error: working_dir: Undefined variable. This could be explained, by the fact that the remote machine do...

linux batch rename directories and strip caracter # from name

Hello, i have a directory with a lot of subdirectories with a # infront of them: #adhasdk #ad18237 I want to rename them all and remove the # caracter I tried to do: rename -n `s/#//g` * but didn't seem to work. -bash: s/#//g: No such file or directory Any ideas on this. Thanks ...

xargs not working

I want all the lines with assert_equal and without amazon. I tried following but it is not working. ack assert_equal | xargs ack -v amazon ...

How can I create a temp file with a specific extension in bash?

I'm writing a shell script, and I need to create a temporary file with a certain extension. I've tried tempname=`basename $0` TMPPS=`mktemp /tmp/${tempname}.XXXXXX.ps` || exit 1 and tempname=`basename $0` TMPPS=`mktemp -t ${tempname}` || exit 1 neither work, as the first creates a file name with a literal "XXXXXX" and the second d...

bash: filter away consecutive lines from text file

I want to delete from many files each instance of a paragraph. I call paragraph a sequence of lines. For example: my first line my second line my third line the fourth 5th and last the problem is that I only want to delete them when they appear as a group. For example, if my first line appears alone I don't want to delete it. ...

bash equivalent of python pass

Is there a bash equivalent to the python pass statement? Thanks. ...

Using a dictionary file with sed

I have a blacklist.txt file that contains keywords I want to remove using sed. Here's what the blacklist.txt file contain winston@linux ] $ cat blacklist.txt obscure keywords here ... And here's what I have so far, but currently doesn't work. blacklist=$(cat blacklist.txt); output="filtered_file.txt" for i in $blacklist; ...

Does anyone have experience with clusters running on ClusterVisionOS?

I'm currently working on a cluster using the ClusterVisionOS 3.1. This will be my first time working with a cluster, so i probably haven't tried the "obvious". I can submit a single job to the cluster with the "qsub" command(this i got working properly) But the problem starts when submitting multiple jobs at once. I could write a script...

Floating Point Comparison in Shell Script

Hello, Can you please suggest me the syntax for doing floating point comparison in shell script. I am using bash. I would ideally like to use as part of if statement here is a small code snippet : key1="12.3" result="12.2" if (( $result <= $key1 )) then # some code here fi thanks Kiran ...

Python vs Bash - In which kind of tasks each one outruns the other performance-wise ?

Obviously Python is more user friendly, a quick search on google shows many results that say that, as Python is byte-compiled is usually faster. I even found this that claims that you can see an improvement of over 2000% on dictionary-based operations. What is your experience on this matter? In which kind of task each one is a clear win...

Multithreading in Bash

I would to introduce multithreading feature in my shell script. I have a script which calls the function read_cfg() with different arguments. Each of these function calls are independent. Would it be possible to instantiate these function calls (not scripts) parallelly. Please let me how can we achieve that.. ? ...

HISTCONTROL=ignoreboth not working debian lenny

Can anybody confirm if by setting the the following env variables under debian lenny will make previous history entries not to be saved. GNU bash, version 3.2.39(1)-release export HISTCONTROL=ignoreboth export HISTSIZE=500 I have added them to my /etc/bash.bashrc but I keep getting repeated commands. Thanks ...

Trouble with piping through sed

I am having trouble piping through sed. Once I have piped output to sed, I cannot pipe the output of sed elsewhere. wget -r -nv http://127.0.0.1:3000/test.html Outputs: 2010-03-12 04:41:48 URL:http://127.0.0.1:3000/test.html [99/99] -> "127.0.0.1:3000/test.html" [1] 2010-03-12 04:41:48 URL:http://127.0.0.1:3000/robots.txt [83/83] -> ...

Bash, no-arguments warning, and case decisions

Hi, I am learning bash. I would like to do a simple script that, when not arguments given, shows some message. And when I give numers as argument,s depending on the value, it does one thing or another. I would also like to know suggestions for the best online manuals for beginners in bash Thanks ...

Turn off error messages in a bash script

Hi, how can one turn off the error messages of a bash script? I want to turn it off, and handle the expected ones by myself For instance, when it does not find some files, to show my specific error message. Thanks ...

Formatting with echo command

The actual situation is a bit complicated, but the issue I'm running into is that I have an echo command within an eval command. Like so: $ eval echo 'keep my spacing' keep my spacing $ echo 'keep my spacing' keep my spacing I was wondering how I could keep eval from stripping my spacing so that the first command pri...

find: What's up with basename and dirname?

I'm using find for a task and I noticed that when I do something like this: find `pwd` -name "file.ext" -exec echo $(dirname {}) \; it will give you dots only for each match. When you s/dirname/basename in that command you get the full pathnames. Am I screwing something up here or is this expected behavior? I'm used to basename givin...

Multiple Progress Bar

Hello, In addition to my previous query concerning multi-threading in shell scripting I am curious if its possible to have multiple progress bar. Here is a code snippet of my expected result : Output : 1 of 100 Files Completed # Thread1 Output : 10 of 45 files Completed # Thread 2 The lines are updated showing the progre...