简体   繁体   中英

Run a single command for every files in a folder- LINUX

I'm a new Linux user and I'm trying to run a single command for every file in a folder (let's call it Tesi). In this folder there are 4000 files and I want to create a new column in each one and put in there the relative file name (later I will merge them all).

I've tried this command, but it doesn't work:

for i in Tesi; do sed -i "s/$/\t$f/" $f; done

Any ideas?

Maybe this solution would be easier:

find <path> -maxdepth 1 -type f -exec sed -i "s/\$/\t\$f/" '{}' \;

If you omit or increase -maxdepth the command will search in subfolders too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM