I am trying to insall f2c/f77 compiler on mac osx using the instructions given http://www.webmo.net/support/fortran_osx.html and I get the following error :
./xsum: Permission denied
make: *** [xsum.out] Error 126
please help , as in installation it misses to create : /usr/local/bin/f2c
I followed the folowing :
chmod +x install_f2c_osx.csh
sudo ./install_f2c_osx.csh
PS : the install_f2c_osx.csh contains the following code :
`#! /bin/csh
setenv INSTALL /usr/local
curl "http://netlib.sandia.gov/cgi-bin/netlib/netlibfiles.tar?filename=netlib/f2c" -o "f2c.tar"
tar -xvf f2c.tar
gunzip -rf f2c/*
cd f2c
mkdir libf2c
mv libf2c.zip libf2c
cd libf2c
unzip libf2c.zip
cp makefile.u Makefile
make
cp f2c.h $INSTALL/include
cp libf2c.a $INSTALL/lib
cd ../src
cp makefile.u Makefile
make
cp f2c $INSTALL/bin
cd ..
mkdir -p $INSTALL/share/man/man1
cp f2c.1t $INSTALL/share/man/man1
cp fc $INSTALL/bin/f77
chmod +x $INSTALL/bin/f77
cd ..
rm -rf f2c
echo "==================SUMMARY=================="
echo $0 " has built and installed:"
find $INSTALL -name '*f2c*' -mmin -5
find $INSTALL -name '*f77*' -mmin -5
For me, #Steele's solution didn't work. Just to document this here: the second solution posted on Superuser actually worked for me, i.e. my xsum binary was not useable by the system, for some reason. In that case, delete the xsum binary that came with f2c and build your own using the xsum.c source. That is, edit the initial code to be:
#! /bin/csh
setenv INSTALL /usr/local
curl "http://netlib.sandia.gov/cgi-bin/netlib/netlibfiles.tar?filename=netlib/f2c" -o "f2c.tar"
tar -xvf f2c.tar
gunzip -rf f2c/*
cd f2c
mkdir libf2c
mv libf2c.zip libf2c
cd libf2c
unzip libf2c.zip
cp makefile.u Makefile
make
cp f2c.h $INSTALL/include
cp libf2c.a $INSTALL/lib
cd ../src
cp makefile.u Makefile
rm xsum #Added
cc -O xsum.c -o xsum #Added
chmod +x xsum #Added
make
cp f2c $INSTALL/bin
cd ..
mkdir -p $INSTALL/share/man/man1
cp f2c.1t $INSTALL/share/man/man1
cp fc $INSTALL/bin/f77
chmod +x $INSTALL/bin/f77
cd ..
rm -rf f2c
echo "==================SUMMARY=================="
echo $0 " has built and installed:"
find $INSTALL -name '*f2c*' -mmin -5
find $INSTALL -name '*f77*' -mmin -5
Related
I'm trying to figure out why is the following tar command not working -
I've tried the following 2 versions & both don't work -
Version 1
tar -c --use-compress-program=pigz -f /home/jhonst/data_lake/1m/UX.tar -C '/home/jhonst/data_lake/1m/*.UX.csv'
The error I see is
tar: Cowardly refusing to create an empty archive
Try 'tar --help' or 'tar --usage' for more information.
Version 2
tar -c --use-compress-program=pigz -f /home/jhonst/data_lake/1m/UX.tar -C '/home/jhonst/data_lake/1m/*.UX.csv' .
The error I see is
tar:
/home/jhonst/data_lake/1m/*.UX.csv: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Please could someone guide me on what I am doing wrong
When you do:
tar -c --use-compress-program=pigz -f /home/jhonst/data_lake/1m/UX.tar /home/jhonst/data_lake/1m/*.UX.csv
You'll get:
tar -t -f /home/jhonst/data_lake/1m/UX.tar
home/jhonst/data_lake/1m/file1.UX.csv
home/jhonst/data_lake/1m/file2.UX.csv
...
Which is not the best. There are two possibilities for getting rid of the "path" inside the tar archive:
Go inside the directory with cd (in a subshell or with pushd/popd if you want to return to the original directory after the tar command):
cd /home/jhonst/data_lake/1m && tar -c --use-compress-program=pigz -f UX.tar *.csv
# returning to the same place after the tar:
(cd /home/jhonst/data_lake/1m && tar -c --use-compress-program=pigz -f UX.tar *.csv)
# or:
pushd /home/jhonst/data_lake/1m && {
tar -c --use-compress-program=pigz -f UX.tar *.csv
popd
}
Use the -C option of GNU tar, which is not that easy to handle:
dirpath=/home/jhonst/data_lake/1m
files=("$dirpath"/*.csv)
tar -c --use-compress-program=pigz -f "$dirpath"/UX.tar -C "$dirpath" "${files[#]#$dirpath/}"
I want to create "make tar" to make tar.gz file from the directory
I do this
KATBIEZ = `basename $(PWD)`
Then I clean because I don't want to have .o i .x file, only c
clean:
rm -f a.out *~ *.o *.x
And this is ma make tar
tar: clean
(cd ..; tar cvzf $(KATBIEZ).tar.gz $(KATBIEZ); ls -altr)
The problem is that in $(KATBIEZ) I have for example "home/Mark/New_Folder/Program10" I want to have only Program10/
So instead of
cd ..; tar cvzf `basename home/Mark/New_Folder/Program10`.tar.gz `basenamehome/Mark/New_Folder/Program10`; ls -altr
I want to have
cd ..; tar cvzf Program10.tar.gz Program10/; ls -altr
Do you have any idea?
What you need is to run basename :
KATBIEZ=$(shell basename "$(PWD)")
To trouble-shoot, run this makefile :
KATBIEZ=$(shell basename "$(PWD)")
tar:
( cd ..; echo tar cvzf "$(KATBIEZ).tar.gz" "$(KATBIEZ)"; ls -altr )
and paste result.
I want to delete a subdirectory which can be in any of the directories using shell script
For eg
The main directory has 3 directories a , b and c and the test folder can be in any of the 3 directories ie a , b, c. so now i want to delete the test directory.So how can we do this
From within main directory:
find . -type d -name 'test' -exec rm -rf {} \;
You have different options to do it but i like use the globstar:
rm -r **/subfolder
Full example:
$ cd /tmp
$ mkdir foo
$ cd foo/
$ mkdir -p bar/zzz
$ mkdir -p bar/aaa
$ mkdir -p bar/bbb
$ mkdir -p xxx/aaa
$ mkdir -p xxx/ccc
$ mkdir -p xxx/ddd
$ rm -r **/aaa
$ ls
bar xxx
You can try to find and then delete it like this:
find . -name test -type d -print0|xargs -0 rm -r --
using find:
find -type d -a -name test
will list all directories with name test, then you can
find -type d -a -name test|xargs rm -r
to remove
If your directories are so similar, you don't need a complex find pipeline, you can use pathname expansion directly:
$ rm -r [abc]/test
So I have a script that takes the zip files in the 2 folders and unzips them into new folders which all works and runs fine
(Folder Names Changed)
But I want to first Know if it is possible to after the files have been unziped and placed in there right folders to then delete the old zip files so all I am left with is the folders and all the unziped files.
And second if it is how would I go about doing that I am new to writing scripts
thanks for any help you can provide
cd ~/Downloads/
mkdir -p -v "./prior/(Folder_Name_1)"
mkdir -p -v "./prior/(Folder_Name_2)"
mkdir -p -v "./prior/(Folder_Name_3)"
mkdir -p -v "./current/(Folder_Name_1)"
mkdir -p -v "./current/(Folder_Name_1)"
mkdir -p -v "./current/(Folder_Name_1)"
tar -xzvf "./prior/Name1.reports.tar.gz" -C "./prior/Folder_Name_1"
tar -xzvf "./prior/Name2.reports.tar.gz" -C "./prior/Folder_Name_2"
tar -xzvf "./prior/Name3.reports.tar.gz" -C "./prior/Folder_Name_3"
tar -xzvf "./current/Name1.reports.tar.gz" -C "./prior/Folder_Name_1"
tar -xzvf "./current/Name2.reports.tar.gz" -C "./prior/Folder_Name_2"
tar -xzvf "./current/Name3.reports.tar.gz" -C "./prior/Folder_Name_3"
I think you want something like this
rm "./prior/Folder_1"
rm "./prior/Folder_2"
rm "./prior/Folder_3"
rm "./current/Folder_1"
rm "./current/Folder_2"
rm "./current/Folder_3"
Question:
I want to untar a tarfile which has many tar files within itself and remove the files in all the tar files and I want all of these processes to run in parallel in Unix bash scripting.
Conditions:
The script should return an error if any untar/remove process has any error.
It should only return success after all N (untar and remove) processes complete successfully.
Proposed solution:
mkdir a
tar -C a -xvf b.tar
cd a
for i in *
do
rm -r $i &
done
If you have GNU Parallel http://www.gnu.org/software/parallel/ installed you can do this:
tar xvf foo.tgz | perl -ne 'print $l;$l=$_;END{print $l}' | parallel rm
It is useful if you do not have space to extract the full tar.gz file, but you need to process files as you unpack them:
tar xvf foo.tgz | perl -ne 'print $l;$l=$_;END{print $l}' | parallel do_stuff {}\; rm {}
You can install GNU Parallel simply by:
wget http://git.savannah.gnu.org/cgit/parallel.git/plain/src/parallel
chmod 755 parallel
cp parallel sem
Watch the intro videos for GNU Parallel to learn more:
https://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
mkdir a
tar -C a -xvf b.tar
cd a
success=$(for i in *
do
rm -r $i || echo failed & # if a job fails false will be echoed
done
wait)
# if any of the jobs failed, success will be set to a value other than ""
[[ -z "$success" ]] && exit 0 || exit 1
The answer tar xvf a.tar | tac | xargs -P 4 rm -rv is inspired from Burton Samograd's comment about xargs -P
$ mkdir -p a/b/c/d
mkdir: created directory `a'
mkdir: created directory `a/b'
mkdir: created directory `a/b/c'
mkdir: created directory `a/b/c/d'
$ touch a/1 a/2 a/3 a/b/4 a/b/5
$ tar cf a.tar a
$ rm -rfv a
removed directory: `a/b/c/d'
removed directory: `a/b/c'
removed `a/b/4'
removed `a/b/5'
removed directory: `a/b'
removed `a/3'
removed `a/1'
removed `a/2'
removed directory: `a'
$ tar xvf a.tar | tac | xargs -P 4 rm -rv
removed `a/2'
removed `a/1'
removed `a/3'
removed `a/b/5'
removed `a/b/4'
removed directory: `a/b/c/d'
removed directory: `a/b/c'
removed directory: `a/b'
removed directory: `a'