LS redirection to a file in same folder

Hello,

I need an input from you all.
I want to redirect the output of 'ls' command to a file
but the file should not display the output file name in it.
scenario:

$pwd
/home/user1
$ls
file1 file2
$ls > file3
$cat file3
file1 file2 file3

In this i dont wish the file3 to be part of the output.
I know if i do redirect to some other folder (ls > /tmp/file3) file3 will not be displayed. :wall:
But can the same be achieved by some option in ls by redirecting to a file in same folder. :rolleyes:

Thanks in advance
Aravind

Is the following possible

ls | grep -v file3 > file3

alternatively:

ls > .file3

Thanks jlliagre
Your suggestion works fine in RHEL.

But on AIX i am still getting the same file name

But i got a suggestion from web to fix this on AIX too. :b::b:

Thanks every one for your inputs :o
Aravind

AIX "ls" exhibits a very non standard behavior. This won't happen if "ls" isn't run as root though.
Here is an alternative more robust than the "sort | tee" hack:

ls >/tmp/ls.$$ && mv /tmp/ls.$$ file3

Thanks again :b::b:
But i am not able to understand this logic :confused: when running this command on AIX.
>> ls | sort | tee 3 displays
1
2

but
>> ls | sort > 3
cat 3 displays
1
2
3
But are input redirection only. Still i am little baffled why the output file (3) is not getting recorded when using "TEE"?
Can you give me some input on this please?

-Aravind

As I wrote this hack isn't robust and might just not work depending on various factors so shouldn't be relied upon.