Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have 4 files let us suppose a,b,c,d in that one is zero byte file.I want a script which will identify which is zero byte file and a script which will transfer this file into "archive" .

Thank You.

share|improve this question

closed as unclear what you're asking by slhck Mar 11 '14 at 7:45

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

Could you show what you have tried yourself? Show the attempted code, and explain where it went wrong and where specifically you need help. –  Bart Arondson Mar 10 '14 at 14:22

1 Answer 1

If you had asked about Linux or the BSDs, things would have been different. There are a whole load of scripting languages available on Linux and the BSDs, from REXX through the TENEX C Shell to Python.

But you specifically asked about UNIX instead.

UNIX is older than Linux and the BSDs, as well as several scripting languages, and you didn't say which version of UNIX you were asking about. To be on the safe side, I've therefore picked a UNIX scripting language that you should be able to use even on Sixth Edition UNIX: the Thompson Shell scripting language.

Here is your script. In the tradition of 1970s UNIX, it is powerful, taciturn, tricky in edge cases, and has no symbol longer than 7 characters. Firmly in the Thompson Tradition, there is no unnecessary letter "e" on the end of archiv. I've made one concession to the GNUistas: the addition of a --help option. If you want to run the script on a BSD, where it will indeed run quite happily, you can of course eliminate such a GNUism with head -11. I have, it almost goes without saying, included the bug that you specified, of only moving one zero-length file. Enjoy.

: L
if ! { fd2 -f /dev/null goto X$1 } goto T 
: T
: <$1''
if -s $1 goto F
goto L
: F
mv $1 archiv/$1
fd2 -f /dev/null goto Y
: X--help
echo Usage: $0 files...
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.