Comments on: concatenate strings in bash http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/ tricks! Thu, 02 Feb 2012 20:46:58 +0000 hourly 1 http://wordpress.org/?v=3.1.1 By: Modifying $NODE_PATH for Node.js/NPM/NVM « Procbits http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-23146 Modifying $NODE_PATH for Node.js/NPM/NVM « Procbits Thu, 20 Oct 2011 15:16:46 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-23146 [...] I didn’t even know why you need to use ‘export’. I didn’t know how to concatenate strings in a bash variable. Or, even how to run a command and capture the output in a variable. I also didn’t know how [...] [...] I didn’t even know why you need to use ‘export’. I didn’t know how to concatenate strings in a bash variable. Or, even how to run a command and capture the output in a variable. I also didn’t know how [...]

]]>
By: vero http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-23020 vero Tue, 11 Oct 2011 14:14:41 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-23020 cheers! ^^ cheers! ^^

]]>
By: P. Terson http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-22692 P. Terson Fri, 26 Aug 2011 20:13:33 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-22692 yay yay

]]>
By: arbit http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-22578 arbit Sun, 14 Aug 2011 02:15:16 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-22578 thank you very much :D thank you very much :D

]]>
By: Ben http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-12699 Ben Mon, 07 Mar 2011 22:59:55 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-12699 Your example works in the case that both variables being concatenated need to be dereferenced at the time of assignment. In the case that you'd like to concatenate variables and not dereference the values. For example, if you are building up the text of a command to be run in the future $format= "$1" $date_cmd= $(echo 'date ' "+$format") Now you can run $date_cmd as a command and it will evaluate each time. Your example works in the case that both variables being concatenated need to be dereferenced at the time of assignment. In the case that you’d like to concatenate variables and not dereference the values. For example, if you are building up the text of a command to be run in the future

$format= “$1″
$date_cmd= $(echo ‘date ‘ “+$format”)

Now you can run $date_cmd as a command and it will evaluate each time.

]]>
By: Helmut http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-12650 Helmut Wed, 23 Feb 2011 13:23:00 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-12650 Hi! How do I get the result of the first line and the second line concatenated into one line and added to a text file, not onto two lines like this does it? ls ./$aa.*|wc -l >> crds.txt; echo "|"$aa >> crds.txt instead of 2347 |agency it should write 2347|agency Thanks! Helmut Hi!
How do I get the result of the first line and the second line concatenated into one line and added to a text file, not onto two lines like this does it?

ls ./$aa.*|wc -l >> crds.txt;
echo “|”$aa >> crds.txt

instead of
2347
|agency

it should write
2347|agency

Thanks!
Helmut

]]>
By: Juha http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-12598 Juha Fri, 11 Feb 2011 06:30:50 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-12598 And for the catenation I used it like this. Tarstring is used as a part of larger command string. for i in ../package/*.jpg;do if [ -f $i ]; then filename=`basename ${i}` tarstring=${tarstring}" "${filename} fi done And for the catenation I used it like this. Tarstring is used as a part of larger command string.

for i in ../package/*.jpg;do
if [ -f $i ]; then
filename=`basename ${i}`
tarstring=${tarstring}” “${filename}
fi
done

]]>
By: Juha http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-12597 Juha Fri, 11 Feb 2011 06:27:48 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-12597 I would do it something like this. Modify it to meet your requirements. Script does not check the input but it could be done with grep and with the same regural expression what the Filename is using. You can make it more efficient by giving the folder with a parameters. But here is a small help. FOLDER=`pwd` cd $FOLDER TRIPNAME=`basename ${FOLDER}` for i in *.avi;do if [ -f $i ]; then FILENAME=`echo $i |sed 's_R\([0-9]*.avi\)_\1_'` echo "mv $i ${TRIPNAME}${FILENAME}" mv $i ${TRIPNAME}${FILENAME} fi done I would do it something like this. Modify it to meet your requirements. Script does not check the input but it could be done with grep and with the same regural expression what the Filename is using. You can make it more efficient by giving the folder with a parameters. But here is a small help.

FOLDER=`pwd`
cd $FOLDER
TRIPNAME=`basename ${FOLDER}`

for i in *.avi;do
if [ -f $i ]; then
FILENAME=`echo $i |sed ‘s_R\([0-9]*.avi\)_\1_’`
echo “mv $i ${TRIPNAME}${FILENAME}”
mv $i ${TRIPNAME}${FILENAME}
fi
done

]]>
By: Lyneham http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-12563 Lyneham Wed, 26 Jan 2011 16:10:39 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-12563 Hi I have a heap of duplicate files (avi and jpegs etc). File names are often sequencenumber.avi, or sequencenumber.jpg The parent directory or a directory in the path contains a better description of what the file is.. eg 2008 Files off Camera/trip to paris/R0001.avi (many files look like this. In those cases I would want the file name to be changed to trip to paris 0001.avi etc. any idea how I might do this? L Hi

I have a heap of duplicate files (avi and jpegs etc).

File names are often sequencenumber.avi, or sequencenumber.jpg

The parent directory or a directory in the path contains a better description of what the file is.. eg 2008 Files off Camera/trip to paris/R0001.avi (many files look like this.

In those cases I would want the file name to be changed to trip to paris 0001.avi etc.

any idea how I might do this?

L

]]>
By: Eric http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/comment-page-1/#comment-12304 Eric Fri, 15 Oct 2010 22:55:56 +0000 http://stinkpot.afraid.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/#comment-12304 thanks. Cool navigation menu btw thanks. Cool navigation menu btw

]]>