LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

File conversion script

Posted 12-29-2012 at 10:04 AM by Snark1994
Updated 12-29-2012 at 10:10 AM by Snark1994

A handy script I put together to automatically convert between file formats based on file extension, in an easily extensible manner:

Code:
#!/usr/bin/env bash

#Conversion rules:
# commands["extension_from extension_to"]="convert_command"
# INFILE and OUTFILE in the conversion command are replaced
# with the appropriate filenames

declare -A commands
commands["wav mp3"]="ffmpeg -i INFILE OUTFILE"
...
Senior Member
Posted in Uncategorized
Views 1496 Comments 0 Snark1994 is offline
Old

Bash quickie: loop N times, without doing math

Posted 10-22-2012 at 09:07 PM by the dsc (linux-related notes)
Updated 03-10-2013 at 12:25 AM by the dsc (improving, varible version)
Tags bash, loop

I thought that the only way to do such type of loop in Bash would require something like "n=$(($n+1))" within the loop, with the loop being conditioned to "n" adding up to whatever you want, such as "until ((n==30)) ; do". But you can actually do "for i in {1..20} ; do <whatever> ; done". That's somewhat similar to Basic's "for i=1 to 20 ; whatever ; next i".

But it won't work with variables for the starting and ending numbers....
Member
Posted in Uncategorized
Views 1702 Comments 0 the dsc is offline
Old

Example script to run and manage a service (tcpdump) with managed logging.

Posted 10-11-2012 at 07:59 PM by konsolebox
Updated 05-27-2018 at 03:10 PM by konsolebox

I made this script as a reply to a question on a thread before. The accidentally simplified complexity of it amazes me so I thought that it would be nice to post this on a blog as well. Original thread: https://www.linuxquestions.org/quest...cpdump-800385/

The script runs and manages a service (tcpdump). It could also automatically delete files older than C days, and reduce the size of a logfile if it's already larger than N bytes....
Senior Member
Posted in Howtos
Views 9369 Comments 0 konsolebox is offline
Old

libfind - Searches library files with keywords and paths from default values and /etc/ld.so.conf.

Posted 09-17-2012 at 01:03 AM by konsolebox
Updated 05-27-2018 at 03:10 PM by konsolebox
Tags bash, script

I made this utility along with binfind. It also has had lots of improvements since then.

This script can be used to search files contained in library files (*.so, *.la, *.a, etc.) based from keywords provided. Along with a custom list of default paths, it will search for libraries inside directories that are specified in /etc/ld.so.conf. It would also examine files that are specified by the "include" directive in it.

After preparations it would search for...
Senior Member
Posted in Howtos
Views 1797 Comments 0 konsolebox is offline
Old

bash sort using a tab delimiter

Posted 09-07-2012 at 01:49 PM by NullTerminator
Updated 09-07-2012 at 02:49 PM by NullTerminator
Tags bash, sort, tab

There are several ways to sort things when fields are tab separated. The simplest I have found is
Code:
TAB=`echo -e "\t"`
sort -t"$TAB" -k 5,3 scrambledFile.tsv > sorted.tsv
syntax may vary for dos shells, possibly as
Code:
set tab=echo "\t"
sort -t"%tab%" -k5,3 scrambledFile.tsv > sortedFile.tsv
As of this posting, both variations are subject to verification of the syntax.
LQ Newbie
Posted in Uncategorized
Views 1197 Comments 0 NullTerminator is offline

  



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

Main Menu
Advertisement
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