Question: New to shell scripting, I have few commands like this. Is it optimal to have such temporary files or should I try to combine all these commands ? if it is latter, can you help me to redirect output from dd command to tr command and then to iconv. Thanks.

dd if=abcd.dat cbs=38 conv=block of=abcd.temp

cat abcd.temp | tr -d "\n" | tr -d "\r" > abcd.output

iconv -f ASCII -t EBCDIC-US <abcd.output > abcd.ebcdic

Answer: 
You can avoid the various intermediate files by using pipes, same as with `tr` in your existing commands. `dd`’s default output (if `of` isn’t specified) can be redirected:

```
dd if=abcd.dat cbs=38 conv=block | tr -d "\n" | tr -d "\r" | iconv -f ASCII -t EBCDIC-US > abcd.ebcdic

```

Both `tr` commands can be combined:

```
dd if=abcd.dat cbs=38 conv=block | tr -d "\n\r" | iconv -f ASCII -t EBCDIC-US > abcd.ebcdic

```
In general, it is usually faster to avoid temporary files as piping output into a second process can allow both processes to overlap processing.

But if the script is more readable using a temporary file, then it should be perfectly acceptable (provided the script removes these files when it has finished with them).

I would tend to treat `dd` as an exception, because it is capable of causing such great damage with the wrong parameters. I would try to avoid its use in a script.

Nice to see good old EBCDIC is still being used!