LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to put two operations on one line execution? (https://www.linuxquestions.org/questions/programming-9/how-to-put-two-operations-on-one-line-execution-4175607484/)

BW-userx 06-07-2017 03:22 PM

how to put two operations on one line execution?
 
How do I put this into one line?
Code:

userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> fs=$(stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3")
userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> echo $fs
319616
userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> size=$(($fs/1024))
userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> echo $size
312

Can it even be done?
Code:

userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> size=$($((stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3"))/1024)
bash: stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3": syntax error: invalid arithmetic operator (error token is ""Elvis Costello-Tramp The Dirt Down.mp3"")
userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> fs=$(size=$((stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3"))/1024)
bash: stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3": syntax error: invalid arithmetic operator (error token is ""Elvis Costello-Tramp The Dirt Down.mp3"")
userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡> fs=$($size=$((stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3"))/1024)
bash: stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3": syntax error: invalid arithmetic operator (error token is ""Elvis Costello-Tramp The Dirt Down.mp3"")
userx%slackwhere ⚡ The Very Best Of Elvis Costello Disc 1 ⚡>


suicidaleggroll 06-07-2017 03:28 PM

Exactly as you'd expect

Code:

fs=$(stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3")
size=$(($fs/1024))

size=$(($(stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3")/1024))


BW-userx 06-07-2017 04:21 PM

Quote:

Originally Posted by suicidaleggroll (Post 5720246)
Exactly as you'd expect

Code:

fs=$(stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3")
size=$(($fs/1024))

size=$(($(stat -c%s "Elvis Costello-Tramp The Dirt Down.mp3")/1024))


results 1:
Code:

#!/bin/bash

#Check for files under 1024 (1 MB) delete them
#June 07, 2017
working_dir="/run/media/userx/3TB-External/X-TOCHECK-MUSIC"
while read FILENAME
do
[[ "$((size=$(($(stat -c%s "$FILENAME")/1024))))" -gt '1024' ]] && echo $size
exit
done< <(find "$working_dir" -type f )

kewl it works!
Code:

userx%slackwhere ⚡ production ⚡> ./DeleteUnder1MB
4396

thanks a load !!


All times are GMT -5. The time now is 05:55 PM.