Cannot stat no such file or directory linux

mv : cannot stat, no such file or directory

mv command is unable to find the file that I’m trying to rename. I’ve looked to solutions involving double quotes, directory expansion and variable evaluation but nothing explains why this Bash script won’t work. I’ve also confirmed that the path is correct and the file exists. If anyone could help I would greatly appreciate it. Below is the code in question with an explanation:

BASEPATH="/media/matt/DATA/Flow_Processing/fvv/rafa_1_ifsc/STEA_flow/" FRSTFRM=00030 LSTFRM=00270 FRSTCAM=001 LSTCAM=012 for cam in $(eval echo "") do for frame in $(eval echo "") do SRC="$$/flow/FVV_0_$_$_flow.flo" DST="$$/flow/FVV_2_$_$frame.flo" mv -f $SRC $DST done done 

So essentially I’m trying to iterate through a file system structure using $cam and $frame variables which are padded strings. I’m trying to change the filenames in each of these folders from:

I’ve printed $SRC and $DST and they output the exact path that I expect. The problem is that in spite of this, mv produces this error:

"cannot stat: : no such file or directory" 

e.g. SRC: /media/matt/DATA/Flow_Processing/fvv/rafa_1_ifsc/STEA_flow/005/flow/FVV_0_005_00190_flow.flo DST: /media/matt/DATA/Flow_Processing/fvv/rafa_1_ifsc/STEA_flow/005/flow/FVV_2_005_00190.flo mv error:

mv: cannot stat '/media/matt/DATA/Flow_Processing/fvv/rafa_1_ifsc/STEA_flow/005/flow/FVV_0_005_00190_flow.flo': No such file or directory 

Источник

Getting an error cp: cannot stat when trying to copy files from one folder to another [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Читайте также:  Arduino ide on linux ubuntu

I have this directory called «mock», which contains 3 directories. I am trying to copy all the items from «mock» directory into the «projweek» directory using the following command:

6 Answers 6

If your source directory is set in quotes, then make sure that the * is outside the quotes, i.e.

good to have this answer here, if you come by search, but not exactly the case of OP, as OP didn’t use quotes. star inside double quotes «*» is taken literally , as a file with a star (*) in its name. End it does not exist.

Note that what’s true for * also goes for ~ . For some reason the only way I could get cp «~/stuff» dest to work was cp «$HOME/stuff» dest .

It’s an odd thing about the unix system that glob expansion (aka use of the » * «) is done by the shell, and not by the program you are calling, and furthermore, if the glob doesn’t match anything, instead of expanding to nothing, it expands to itself and passes that to the program. So the cp command sees literally «/mock/ * » which doesn’t exist, because you have no file called » * «. Somewhat perversely if you had a file called » * » it would dutifully copy it without complaining.

cannot stat = file/dir does not exist. Check the path first.

And, you say you want to copy /mock but the error message says mock . Show the real code first.

When I test in ubuntu, cp (GNU coreutils) 8.28 , I have no problem with copying all files under a dir to another dir, when both paths are correct.

root@DESKTOP-9NHNV2I:~# cp /root/temp/* /root root@DESKTOP-9NHNV2I:~# ls temp test.txt test2.txt test3333.txt 

Источник

Читайте также:  Linux what version of php

mv: cannot stat with *

I can think of 2 possible reasons why this can happen:

You need to use $USER for user to expand to your username. /home/user is only valid if you have a user named user . This will work if temp1 and temp2 exists in your home directory

mv /home/$USER/temp1/* /home/$USER/temp2 

I’ll try to help out and clear up the confusion a little:

  • If you want to move a folder and its contents to another one, you enter: mv ~/Scripts ~/Podcasts
  • If you want to move a folder’s contents but not the folder itself to another folder, you must enter, for example, mv ~/Scripts/* ~/Podcasts . You can enter echo ~/Scripts/* to check the folder’s content
  • (If you also need to know about globstar , which will allow you to recurse through all directory levels, see this article and this one. It can be enabled with shopt -s globstar, but that will need to be put in .bashrc to work permanently.)

(The tilde ~ in ~/Scripts is expanded to /home/mike/ or your user name automatically by the shell)

If you’re using bash and the source directory is empty, you can modify the shell’s default glob expansion behavior with:

to enable the nullglob and cause any succeeding commands like mv to behave properly when the source directory is empty. Beware that this can cause other commands such as ls to behave unexpectedly.

You can disable the nullglob again with:

For more information, look here and here.

Источник

Bash, tar «cannot stat no such file or directory» [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

  • This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
  • This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Читайте также:  Операционная система симпли линукс

I’m trying to build a little backup script but I keep getting the following error:

tar: Removing leading `/' from member names tar: /projects: Cannot stat: No such file or directory tar: Exiting with failure status due to previous errors 

The folder /projects exists, but still no tar ball is created. Here is my code:

#!/bin/bash backup_files="/projects" #destination of backup dest="/" #Create archive filename day=$(date +%Y-%m-%d) hostname=$(hostname -s) archive_file="$hostname-$day.tar.gz" #Backup the files using tar tar -czf $archive_file $backup_files #Print end status message echo echo "Backup finished" 

ls -ld /projects shows the following:

ls: cannot access /projects: No such file or directory 

Any idea on what is wrong?

1 Answer 1

Filepaths that start with a leading / on Linux and other related systems are located at the root directory. This means that «/projects» usually refers to a different directory than «projects» .

It looks like you probably are trying to access a subdirectory /path/to/projects from directory /path/to using the path /projects . This is incorrect — if your working directory is /path/to , you need to access folder projects by changing backup_files=»/projects» to backup_files=»./projects» — «.» refers to the current working directory — or simply backup_files=»projects» .

So, while relative filepaths «./projects» and «projects» are usually equivalent, they are generally and functionally different from the fully qualified path «/projects» .

Источник

Оцените статью
Adblock
detector