Search Results

Search: Posts Made By: jimbojames
1,434
Posted By Corona688
eval is dangerous. Why not save just the script...
eval is dangerous. Why not save just the script name, and feed the variable into it later?
1,434
Posted By Don Cragun
Not exactly. When we look at: ...
Not exactly. When we look at:
SCRIPT="./MY_SCRIPT.ksh ${VAR5}"
eval "$SCRIPT"
What is being suggested here is probably not what is wanted.

If the intent is to expand $VAR5 at the time SCRIPT...
1,434
Posted By Yoda
Wrap it in double quotes and use eval ...
Wrap it in double quotes and use eval
SCRIPT="./MY_SCRIPT.ksh ${VAR5}"

eval "$SCRIPT"
3,104
Posted By Yoda
Bash pattern replacement: for file in...
Bash pattern replacement:
for file in *.[Cc][Ss][Vv]; do echo ${file//[^0-9]/}; done
3,104
Posted By neutronscott
I would not use ls nor awk at all but globbing in...
I would not use ls nor awk at all but globbing in the shell.


$ for f in *.[Cc][Ss][Vv]; do echo "$f"; dt=${f##*_}; dt=${dt%%.*}; echo "$dt"; done
MYFILE_NAME_20130221000026.CSV
20130221000026
3,104
Posted By spacebar
This is one way to do it: $...
This is one way to do it:
$ FILEN="MYFILE_NAME_20130221000026.CSV"

$ datetime=$(echo $FILEN | tr -cd '[[:digit:]]')

$ echo $datetime
20130221000026
7,608
Posted By RudiC
Good you found a fix by yourself! Still, for e.g....
Good you found a fix by yourself! Still, for e.g. later reference, these were the errors in your first script, which you did not correct but circumvent:
a) put the redirection inside the command...
7,608
Posted By RudiC
Hmmm - sounds reasonable, but (linux, bash):$...
Hmmm - sounds reasonable, but (linux, bash):$ X=$(ls xyyxyx 2>/dev/null)
$ echo $?, ">"$X"<"
2, ><
while $ X=""
$ echo $?, ">"$X"<"
0, ><
So the 2 would be the ls' exit status, wouldn't it?
7,608
Posted By bakunin
This is correct, but even var=$(command;...
This is correct, but even

var=$(command; command)
echo $?

Will show only the exit status of the last command, which is a variable assignment. The exit code will be that of var=someting, not...
55,920
Posted By Arun_Linux
If you want to capture the raw output then this...
If you want to capture the raw output then this might help,

x = `ssh -f ${SOURCE_SERV} ls -l ${SOURCE_FOLDER/${FILE}`

x will contain the file name if it exists else it will be empty.
1,858
Posted By chihung
What you can do is to remove the leading zero...
What you can do is to remove the leading zero before you feed into awk. Try this

set -- `date '+%b %d'`
mth=$1
day=${2#0}
awk -v d="$mth$day" '/user:warn/ && /has shutdown/ && ($1$2 == d){...
86,987
Posted By itkamaraj
find . -mtime 0 # find files modified between...
find . -mtime 0 # find files modified between now and 1 day ago
# (i.e., within the past 24 hours)
find . -mtime -1 # find files modified less than 1 day ago
...
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 05:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy