LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2017, 03:22 PM   #1
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,677

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
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 ⚡>
 
Old 06-07-2017, 03:28 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,520

Rep: Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106Reputation: 2106
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))
 
1 members found this post helpful.
Old 06-07-2017, 04:21 PM   #3
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 4,677

Original Poster
Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Quote:
Originally Posted by suicidaleggroll View Post
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 !!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron execution using command line desiretolearn Linux - Newbie 5 02-05-2014 12:46 PM
[SOLVED] Thread Execution Line Question varoluscuprens Programming 1 05-03-2012 08:50 AM
command line execution vs clicking on the icon icecubeflower Linux - Newbie 2 04-19-2009 04:39 PM
Logging all mysql command line operations Linville79 Linux - Server 8 06-19-2008 01:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration