The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
printing first n lines in a file without using head dareman123 Shell Programming and Scripting 7 09-24-2008 05:48 AM
Howto get readline to work in shellscript (stdin) sentinel UNIX for Dummies Questions & Answers 3 09-15-2008 08:28 PM
how to save to file as head rows_numbers big_file mr_bold UNIX for Dummies Questions & Answers 2 03-12-2007 02:32 AM
head command wont work on MF file alfredo123 UNIX for Dummies Questions & Answers 10 03-04-2007 10:23 AM
help.. I am in way over my head !!!! oberon42 UNIX for Dummies Questions & Answers 3 04-26-2002 12:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-15-2009
unclecameron unclecameron is offline VIP Member  
VIP Member
  
 

Join Date: Nov 2008
Posts: 37
cat vs head vs readline get variable from txt file

I have a file with a single filename in it, which I want to assign to a BASH variable, so I've been trying:

c=$(head -1 somefile)
echo $c

which outputs correctly, but them when I do

...
somecommand $c

it says it can't find the file, is that because it's grabbing the whole line, and how should I be doing it different, grep maybe?
  #2 (permalink)  
Old 04-15-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is online now Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,403
whats that somecommand?? and is that file available on the dir where you are running that script??
  #3 (permalink)  
Old 04-15-2009
unclecameron unclecameron is offline VIP Member  
VIP Member
  
 

Join Date: Nov 2008
Posts: 37

Code:
#!/bin/bash
c=$(head -1 toconvertfile)
ffmpeg -i $c -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 512000 -bt 512000 -threads 0 -s 600x400 -r 30 -f flv $c.tempfile
ffmpeg -i $c -acodec libfaac -ab 64k -pass 2 -vcodec libx264 -vpre hq -b 512000 -bt 512000 -threads 0 -s 600x400 -r 30 -f flv $c.flv
rm $c.tempfile
ffmpeg -i $c.flv -s 174x116 -an -ss 5 -vframes 1 -f image2 -y $c.flv.jpg

#: cat toconvertfile
test1.avi

#: ls test1.*
test1.avi

if I just use


Code:
#!/bin/bash
ffmpeg -i $1 -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 512000 -bt 512000 -threads 0 -s 600x400 -r 30 -f flv $1.tempfile
ffmpeg -i $1 -acodec libfaac -ab 64k -pass 2 -vcodec libx264 -vpre hq -b 512000 -bt 512000 -threads 0 -s 600x400 -r 30 -f flv $1.flv
rm $1.tempfile
ffmpeg -i $1.flv -s 174x116 -an -ss 5 -vframes 1 -f image2 -y $1.flv.jpg

with

#: ./conv.sh test1.avi

it works
  #4 (permalink)  
Old 04-15-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is online now Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,403
can you post the out put of

Code:
cat -vet toconvertfile
c=$(head -1 toconvertfile)
echo "$c"|cat -vet
echo "$c"

  #5 (permalink)  
Old 04-15-2009
unclecameron unclecameron is offline VIP Member  
VIP Member
  
 

Join Date: Nov 2008
Posts: 37

Code:
# cat -vet toconvertfile
test1.avi$
# c=$(head -1 toconvertfile)
# echo "$c"|cat -vet
test1.avi$
t# echo "$c"
test1.avi

  #6 (permalink)  
Old 04-16-2009
unclecameron unclecameron is offline VIP Member  
VIP Member
  
 

Join Date: Nov 2008
Posts: 37
okay, well I got it to work, thanks for the help, the final code is this:


Code:

#!/bin/bash
while [ 1 = 1 ]
 do
    c=$(head -1 toconvertfile)
  for i in $c
    do
      ffmpeg -i $c -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 512000 -bt 512000 -threads 0 -s 600x400 -r 30 -f flv $c.tempfile
      ffmpeg -i $c -acodec libfaac -ab 64k -pass 2 -vcodec libx264 -vpre hq -b 512000 -bt 512000 -threads 0 -s 600x400 -r 30 -f flv $c.flv
      ffmpeg -i $c.flv -s 174x116 -an -ss 5 -vframes 1 -f image2 -y $c.flv.jpg
      rm $c.tempfile
      cat /dev/null > toconvertfile
      done
sleep 30
done


Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0