Question: I am stuck in the below scenario.

I have added these in one script named : small\_script.sh

```
#!/bin/bash

uname
uname -r
uname -a
pwd

```

I need the timestamp in seconds for every line displaying in the terminal and needs to write to a file .. Hence I implemented as below :

```
./small_script.sh | while read R; do echo "$(date +%s) $R"; done | tee output.txt

1526635998 Darwin
1526635998 17.4.0
1526635998 Darwin C02V41QWHV2R 17.4.0 Darwin Kernel Version 17.4.0 ..
1526635998 /Users/home/duraja

```

Now, my query is I am looking for output in terminal where first column (date in seconds) doesnt show, but the first column (date in seconds) should be there in my text file. 

Sample Output expectation .. 

The terminal output should show

```
Darwin
17.4.0
Darwin C02V41QWHV2R 17.4.0 Darwin Kernel Version 17.4.0 ..
/Users/home/duraja

```

The text file output should show

```
1526635998 Darwin
1526635998 17.4.0
1526635998 Darwin C02V41QWHV2R 17.4.0 Darwin Kernel Version 17.4.0 ..
1526635998 /Users/home/duraja

```

How can I achieve it ? Please suggest.

Answer: 
You are ignoring the result of the recursive call to `sorted`. Just return it, and you should be fine:

```
boolean sorted(int[] a , int s , int n)
{
    if(s+1==n)
        return true ;
    if(a[s]<=a[s+1])
        return sorted(a,s+1,n); // Here!      
    return false ;
}

```
You don't use result of recursive call. Perhaps it may look like

```
 if(a[s]<=a[s+1])
      return sorted(a,s+1,n)
 else
     return false;

```

or (if Java uses fast evaluation of complex conditions):

```
return (a[s]<=a[s+1]) && (sorted(a,s+1,n))

```