chgroup -R <groupname> <file/foldername>
...this is a log of code snippets and useful tips I wrote/found. Should you find any mistakes or have any useful suggestions, please do not hesitate to write to me.
Showing posts with label linux/unix commands. Show all posts
Showing posts with label linux/unix commands. Show all posts
Monday, March 24, 2014
Monday, February 10, 2014
unix command to remove everything after a character in a string
suppose you want to remove everything in a string after the character '_'
The command you would use would be:
i=<your string>
j=${i%%_*}
something i have used in the past.
for i in $(ls); do cd ../$i|cut -d '_' -f1; echo pwd; cd ../geo_color/; done
The command you would use would be:
i=<your string>
j=${i%%_*}
something i have used in the past.
for i in $(ls); do cd ../$i|cut -d '_' -f1; echo pwd; cd ../geo_color/; done
Using visual bloc to paste chunks of data
I was having trouble pasting text selected using vim's visual block into a new file.
The copy command is 'y'
The paste command is 'p'
the delete command is 'd' or 'x'
However, the delete command seems to leave behind empty lines. use ':g/^$/d' to remove empty lines from a file
The copy command is 'y'
The paste command is 'p'
the delete command is 'd' or 'x'
However, the delete command seems to leave behind empty lines. use ':g/^$/d' to remove empty lines from a file
Thursday, February 6, 2014
Tuesday, November 19, 2013
Searching and Replacing strings in vi
:%s/pattern/replace/if you are searching for a special character( '.', '$' etc), precede it with '\' Wednesday, October 9, 2013
using nohup
nohup matlab -nodisplay -nosplash -r Script1 > out.txt &
Edit
f you want to run a function with variables, this is how to do it:
nohup matlab -nodisplay -nosplash -r "funcitonabcc(var1,var2,..,varn); exit; " > out.txt &
the text within the double quotes needs to be written just as you would call commands in matlab.
Edit
f you want to run a function with variables, this is how to do it:
nohup matlab -nodisplay -nosplash -r "funcitonabcc(var1,var2,..,varn); exit; " > out.txt &
the text within the double quotes needs to be written just as you would call commands in matlab.
Sunday, September 15, 2013
a script for counting images/features
for i in $(ls);
do
cd $i;
imcount=`ls |wc -l`;
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
for j in $(ls);
do
cd $j;
fcount=`ls|wc -l`;
if [ "$imcount" -ne "$fcount" ]; then
echo $i;
echo $imcount
echo $j;
echo $fcount;
fi
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
done
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/image;
done
do
cd $i;
imcount=`ls |wc -l`;
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
for j in $(ls);
do
cd $j;
fcount=`ls|wc -l`;
if [ "$imcount" -ne "$fcount" ]; then
echo $i;
echo $imcount
echo $j;
echo $fcount;
fi
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
done
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/image;
done
Some file operations in unix
for i in $(ls); do h=`echo $i|cut -d '_' -f1`; echo $h; done
This lists all the files in the current dir, and ehos a part of their name. thsi h can then be used as a directory location
This lists all the files in the current dir, and ehos a part of their name. thsi h can then be used as a directory location
Subscribe to:
Posts (Atom)