LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Original Poster
Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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



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:45 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
Open Source Consulting | Domain Registration