Sponsored Content
Top Forums Shell Programming and Scripting Clear contents of specified directories, then return exit status Post 302980393 by YouNicks on Friday 26th of August 2016 04:39:41 PM
Old 08-26-2016
Clear contents of specified directories, then return exit status

Hello, this is my first post here.

I'm attempting to write a bash shell script to rm the contents of a directory without deleting the directory, specifically in OS X 10.10 . Here's what I have:

Code:
function clear() {
USER="$USER"
DIR=$1

rm -rfv /Users/"$USER"/library/$DIR/*
}

clear caches
clear Saved Application State
clear LaunchAgents

if [ "$?" -eq "0" ]
then
echo "Command succeeded"
exit 0
else
echo "Command failed"
exit 1
fi

It's not actually clearing anything but the caches directory and also stating that my permission is denied on Xamarin Font services or something.

Code:
rm: /Users/joshuaevans/library/caches/com.xamarin.fontconfig/84c0f976e30e948e99073af70f4ae876-le32d4.cache-3: Permission denied
rm: /Users/joshuaevans/library/caches/com.xamarin.fontconfig/8d7231e6733a9725c81b40e9f55f11b1-le32d4.cache-3: Permission denied
rm: /Users/joshuaevans/library/caches/com.xamarin.fontconfig/b0a71e6bf6a8a1a908413a823d76e21f-le32d4.cache-3: Permission denied
rm: /Users/joshuaevans/library/caches/com.xamarin.fontconfig/CACHEDIR.TAG: Permission denied
rm: /Users/joshuaevans/library/caches/com.xamarin.fontconfig: Directory not empty

Any suggestions?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

exit status

i downloaded a text file from metalab.unc.edu called sh.txt and in this reference manual it refers to shell scripting exit status .. at the end of one of the examples that author gave an exit status of 127.. to what does a 127 exit status refer too and what is its purpose in the code. moxxx68 (1 Reply)
Discussion started by: moxxx68
1 Replies

2. UNIX for Advanced & Expert Users

clear CLOSE_WAIT status

Hi, I have an application with a bug in it that keeps sockets in CLOSE_WAIT, which eventually freezes the server because the user account it runs under runs out of file handles. We have the bug fixed but can only release the fix with the next release. Does anyone know how I can clear the... (3 Replies)
Discussion started by: rein
3 Replies

3. HP-UX

Return of EXIT status ( $? )

I have the question: How return the exit code from then assign : VAR=$(command ) for ex. VAR=$(ls ....) VAREXIT=$? echo $VAREXIT VAREXIT is equal to 0 if the directory exist or not exist. WHI?? if i execute the command direct from line-command , the value of $? is different if... (1 Reply)
Discussion started by: ZINGARO
1 Replies

4. Shell Programming and Scripting

How to get the exit status

Hi all, I'm running a program which return 1 upon success. But when encounters problem shell return 's '1' . How to differentiate between them the shell return value and script return value. Ex. function fn return '1' if executed successfully and '0' if failed. But when if shell encounters... (1 Reply)
Discussion started by: yhacks
1 Replies

5. Shell Programming and Scripting

Clear Terminal After Exit

I have had a look around and can not find the answer, I dont think im searching for the right phrase. I have written a script to control common functions on my server, however when exiting the script the terminal starts directly below the script that was running... how can i clear this so it... (2 Replies)
Discussion started by: foz
2 Replies

6. Shell Programming and Scripting

command does not return exit status due to tee

Hi, I am using /bin/sh. I want to display the stdout and stderr on the terminal as well as save it in a file, so I'm using this command. gmake all 2>&1 | tee log But even if gmake fails, it's always giving 0 as exit status, i suppose because of tee. # false 2>&1 | tee Log # echo $? 0... (2 Replies)
Discussion started by: anand_bh
2 Replies

7. Shell Programming and Scripting

Exit Status

I have a shell script (#!/bin/sh) that interacts with Appworx and Banner Admin. In my script I want to check the exit status of awrun before continuing. awrun can run for 10 seconds or it can run for over a minute. So my question is, will it go through my if statement before awrun may even be... (2 Replies)
Discussion started by: smkremer
2 Replies

8. Shell Programming and Scripting

How to clear contents of a file without deleting it.

Hi, I have a script which will use an input.txt file as an input file. I am providing data to this input file in the script and once the script is executed, I want to clear all the contents of this file as during the second time use of this script, I'll be appending the data in this input... (5 Replies)
Discussion started by: pat_pramod
5 Replies

9. Shell Programming and Scripting

Want to get the exit status

Hi All, I am trying to create a zip file with all the txt files(these are in large number) in the current directory. I am able to do this operation sucessfully. After this i want to get the status of the tar command executed and do accordingly. When i am trying with the below code, the status... (3 Replies)
Discussion started by: paddu
3 Replies

10. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
FC-CACHE(1)															       FC-CACHE(1)

NAME
fc-cache - build font information cache files SYNOPSIS
fc-cache [ -fsvV? ] [ --force ] [ --system-only ] [ --verbose ] [ --version ] [ --help ] [ dirs ] DESCRIPTION
fc-cache scans the font directories on the system and builds font information cache files for applications using fontconfig for their font handling. If directory arguments are not given, fc-cache uses each directory in the current font configuration. Each directory is scanned for font files readable by FreeType. A cache is created which contains properties of each font and the associated filename. This cache is used to speed up application startup when using the fontconfig library. Note that fc-cache must be executed once per architecture to generate font information customized for that architecture. On a subsequent run, fc-cache will augment the cache information files with the information for the new architecture. OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -f --force Force re-generation of apparently up-to-date cache files, overriding the timestamp checking. -s --system-only Only scan system-wide directories, omitting the places located in the user's home directory. -v --verbose Display status information while busy. -? --help Show summary of options. -V --version Show version of the program and exit. dirs A list of directories to scan for fonts. FILES
fonts.cache-2 These files are generated by fc-cache and contain maps from file names to font properties. They are read by the fontconfig library at application startup to locate appropriate fonts. SEE ALSO
fc-list (1). The fontconfig user's guide, in HTML format: /usr/share/doc/fontconfig/fontconfig-user.html. AUTHOR
This manual page was written by Keith Packard <keithp@keithp.com> and Josselin Mouette <joss@debian.org>. 05 May 2008 FC-CACHE(1)
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy