简体   繁体   中英

I want to get filename from different server and store in a variable

I want to get the file name from different server and store it in a variable.

example: from 1 server I want to get the file name using below command

FILE_NAME=$(ssh user@host ls /acd/file/zipped/processing/trigger/Daily_trigger_$DATE*.csv*)

but FILE_NAME stores complete path and filename:

/acd/file/zipped/processing/trigger/Daily_trigger_19072021_220305.csv

I only want the filename.

If your system has basename , you can use it, as in jhnc's comment, above.

If you want a pure bash solution, you can use

${FILE_NAME##*/}

to get only the filename part. See Shell Parameter expansion in the bash manual for more.

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