Sed Permission Denied When Overwriting File

permission denied when sed in place edit in mingw

It's caused by Windows security settings.

Open the folder's Properties settings from the context menu. In the Security tab, click Edit, press Add... in the pop-up window and add your user to the list, check Full Control in the Allow column. Press OK twice to apply the changes.

What causes Permission denied when using sed?

Is $config_out the name of a file or a command? If it's a file, then you need to either cat $config_out | sed ... or sed ... < $config_out > $config_out.tmp. If it's a command, though, the first command might have truncated/overwritten whatever it was (shell script or perl script or something?).

Permission denied error using sed to change file name

You want to force evaluation on basename-sed pipe. ( with '$(' ) and handle the quoting)

outputname=$(basename $file | sed -e "s/_Aligned.sortedByCoord.out.bam/_.gtf/")

Or using Bash built-in only, which will be much FASTER.

file_base=${file##*/}
outputname=${file_base/_Aligned.sortedByCoord.out.bam/_.gtf}

find and rename files gives bash 'no such file or directory' error

Probably you don't have rename command on your system. Try this instead:

for file in ./*.json; do
echo mv "$file" "${file%-*}.json"
done

Drop the echo if the output looks fine.



Related Topics



Leave a reply



Submit