Execution Error!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Execution Error!
# 8  
Old 01-22-2014
In case you got such an output with a for loop
Code:
for word in `ls -l`
do
 echo "$word"
done

you better use a while loop
Code:
ls -l |
while read line
do
 echo "$line"
done

Please always quote $var: "$var"!
# 9  
Old 01-25-2014
Hi, Sorry for the delay, by the way Thanks for the inputs..
Actually I am trying to open file that has been modified today (E.g: by using Today's date)
I have written in a script like:

Code:
dated=`date '+%b %d'` #I wanted to search like for e.g., if today's date is January 26 2014, then dated variable will have Jan 26.
fileslist=`ls -lt  | grep "$dated"`
for i in $fileslist
do
echo $i
done

I am willing to get the file names only and those should get opened.
Is there any other way I could do. Please help me out.

Last edited by Neo; 01-25-2014 at 03:57 PM.. Reason: Last warning to add code tags... infraction next.
# 10  
Old 01-27-2014
Code:
\ls -lt | grep "$dated" |
while read x x x x x x x x file
do
  [ -f "$file" ] || continue # skip directories
  echo "$file"
done

Or get the files from the last 24 hours:
Code:
find . -type d \! -name . -prune -o -mtime 0 -print |
while read file
do
  echo "$file"
done

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Stop script execution, when we encounter error

Team, Im new to shell scripting please help in below issue: Considering scenario i have 1.sql,2.sql,3.sql and 4.sql . If my second script fails my loop should come out and should not execute 3.sql and 4.sql. Here is my code. #! /bin/bash echo "exit" | user/password | grep Connected >... (4 Replies)
Discussion started by: preethi87
4 Replies

2. AIX

Error while script execution - 0403-029 there is not enough memory available now

Hi, I am executing a shell script on AIX box where I need to list all the files in the file system and then do some other tasks with them. I am able to do this successfully on HP-UX and Linux boxes but I get the following error after 10-15 seconds when I try to execute the script on an AIX box. ... (6 Replies)
Discussion started by: Adyan Faruqi
6 Replies

3. Programming

Solr--Basic Example execution error

Hello , I am new bee to Solr and trying to run sample example for solr . java -Durl=http://locahost:8983/solr/update -jar post.jar books.csv Error SimplePostTool version 1.5 Posting files to base url http://locahost:8983/solr/update using content-type... (3 Replies)
Discussion started by: Tomlight
3 Replies

4. Shell Programming and Scripting

Syntax error in sh script execution

Script: #!/sbin/sh echo "Welcome to my First Script" echo "Enter a word" read PASS if then echo "You are correct" elif then echo "Thats incorrect" else echo "Bye" fi When i run the script shell says: Syntax error at line 7:'elif' is not expected I ran through some old posts and... (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

5. Shell Programming and Scripting

Execution of shell script returns error 127

Hi All, While running shell script i got following output. interpreter "usr/bin/ksh" not found sh: step1.sh: not found. ldnhpux | oracle >echo $? 127 - Running command "which ksh" retruns "usr/bin/ksh". - I found some information on web stating to remove extra carriage return chars,... (8 Replies)
Discussion started by: RuchirP
8 Replies

6. Shell Programming and Scripting

Execution error with awk script

Hi, I run an awk script and I got the error attached below: here are the lines that the compiler point to as an error: duration = timeEnd1-timeBegin1; print "Transmission: type of traffic " flow1 ; print “ - Total transmitted bits = ” totalBits1 ” bits”; print “ - duration = ”... (2 Replies)
Discussion started by: ENG_MOHD
2 Replies

7. Shell Programming and Scripting

Expect Issue Serial Forground Execution vs Concurrent Background Execution

I have an expect script that interrogates several hundred unix servers for both access and directories therein using "ssh user@host ls -l /path". The combination of host/path are unique but the host may be interrogated multiple times if there are multiple paths to test. The expect script is run... (2 Replies)
Discussion started by: twk
2 Replies

8. Shell Programming and Scripting

SolarisCron job perl script execution error

Hi, I want to run a crontab job on solaris10.5. I have configured the crontab accordingly 10 * * * * /scripts/dbalter.pl >> /scripts/cronout.txt.However this does not work .Then I go to /var/mail/root and find an error in the output:... (4 Replies)
Discussion started by: sonu2die4
4 Replies

9. Shell Programming and Scripting

error during the execution of script

Hi, I have a cron job which executes daily once 9 PM. The script is like if then TYPE=OC elif then TYPE=i elif then TYPE=mmc elif then TYPE=CB elif then TYPE=oth fi (1 Reply)
Discussion started by: surjyap
1 Replies

10. Programming

metamail execution error

Hi. I´m have installed the metamail from skunkware and when I´m trying to use mailto (the complete script is bellow), I got this message: # mailto To: test@bla.com Subject: test ~/2048000 Set splitsize to 2048000 ~* Please choose which kind of data you wish to insert: 0: A raw file,... (2 Replies)
Discussion started by: ahnishimi
2 Replies
Login or Register to Ask a Question