Uniq redirect to file fails - No such file or directory

I can’t understand why I am getting “No such file or directory” when using the command
uniq –u $PBS_NODEFILE > /mntnfs/nodes/nodelist.txt

I perform an ls on the folder to make sure the file is there. I can read the source file /var/spool/pbs/aux/249.headnode. Can anyone point out what is going wrong here?

#PBS -l nodes=3:ppn=34
#PBS -N Job1
#PBS -j oe
#PBS -o cn-1:/mntnfs/pbsoutput

ls /mntnfs/nodes/

uniq –u $PBS_NODEFILE > /mntnfs/nodes/nodelist.txt

uniq: –u: No such file or directory

$PBS_NODEDILE is not a file but a string array. Echo it to a file or use | to feed to uniq.


Henry Wu|吴光宇

It looks to me like your uniq command isn’t recognizing


as an argument but as a filename.

  1. Did you by chance cut and paste this command from something that honors Unicode and not ascii? (Visually it looks that way to me, but I have no idea if that’s just the formatting of the web page or if the script is like that too). I would double check that the “u” is actually proceeded by a hyphen and not some other kind of Unicode delimiter like an em-dash. I’ve actually had users accidentally cut and paste smileys into scripts before.
  2. If not the first item, are you sure your PATH is pointing to the /bin/uniq or /usr/bin/uniq? Maybe you should have a “which uniq” command to your script. It’s also possible that your PATH in your script environment is running some other command (with the same name) that doesn’t honor the -u argument.
  3. Similar to #2, are you sure the copy of uniq you are invoking honors the -u argument?

Could you please replace this line by the below line
cat $PBS_NODEFILE | uniq > /mntnfs/nodes/nodelist.txt

1 Like

I tried the command you reference and it works fine. I’m not sure why the uniq -u or -d will not work with the .SC job file that is created. Any idea why?

Thanks for the response. I really appreciate it!

I’m using dash u in the script “uniq -u”. I tried this from command line with a file and it works without issue.

Thanks for responding. I don’t spend much time in linux. I didn’t realise there was something called a string array. The $PBS_NODEFILE name may have mislead me then. I just assumed it was a file.

$PBS_NODEFILE points to a file located on the mother superior node ( first node listed in the output of qstat -fx < jobid > | grep -i exec_vnode output ). This file is created dynamically by PBS Pro.

Please try this :
[pbsdata@pbsserver ~]$ qsub -I
qsub: waiting for job 210.pbsserver to start
qsub: job 210.pbsserver ready

[pbsdata@computenode ~]$ echo $PBS_NODEFILE

I have tested uniq -u $PBS_NODEFILE on my test machine and it worked for me

I suspect the hypen in front of u of the uniq -u command has issues or it must have been copy pasted from a window system , so it might be windows hypen, plese delete that hypen and test it.