Search Results

Search: Posts Made By: azherkn3
1,214
Posted By Don Cragun
Since wc includes leading spaces in its output,...
Since wc includes leading spaces in its output, try it without the quotes:
if [ $count -gt 1000 ]
1,807
Posted By Akshay Hegde
This might help you $ file=sample.csv $...
This might help you
$ file=sample.csv

$ now=$(date +"%m_%d_%Y")

$ newfile="${file%.*}_$now.${file##*.}"

$ echo $newfile
sample_02_05_2014.csv
1,807
Posted By rbatte1
Remember that if you "name" portion of the...
Remember that if you "name" portion of the filename contain full stops ., then you will have to adjust the suggestion from anbu23 to cater for that.

Perhaps:-mv "${file}"...
2,007
Posted By clx
Which shell are you using? Has the command...
Which shell are you using? Has the command executed successfully?
Try running the script manually and check whether the value of $run is being incremented correctly.

If you face any issues, Try...
2,007
Posted By clx
Exists where? IS it exist in the $HOME of the...
Exists where? IS it exist in the $HOME of the cron user?
As I said earlier please provide full path of the path (starts with "/").






You can't use absolute numbers as the variables name....
2,007
Posted By clx
1. You must have spaces on both side of opening...
1. You must have spaces on both side of opening and closing square brackets.

if [ $run -eq 10 ]; then


2. Make sure 'samp.csv' exists, Probably it exists in your current directory. Provide...
2,526
Posted By balajesuri
-o pid is a format specifier for the ps command...
-o pid is a format specifier for the ps command that prints only the PID's of the processes specfied by the -c switch (in this case "myscript.sh"). But this will print the default column header name...
2,526
Posted By balajesuri
kill $(ps -C "myscript.sh" -o pid=)
kill $(ps -C "myscript.sh" -o pid=)
2,526
Posted By balajesuri
Why are you running the script in the first...
Why are you running the script in the first place, if you want to later find it's pid and kill it? This doesn't appear to be an efficient way of achieving your task. What exactly do you want to...
1,228
Posted By Don Cragun
I would suggest using at instead of cron. Use a...
I would suggest using at instead of cron. Use a file to keep track of how many times the job has run. When the job is ready to exit, it can update the count of how many time it has run, and if it...
1,228
Posted By Don Cragun
Jobs run by cron are not interactive; they don't...
Jobs run by cron are not interactive; they don't have a connection to your keyboard.
1,422
Posted By RudiC
This may not be an adequate request for cron....
This may not be an adequate request for cron. Your entry will start at 10 min past each full hour and this will continue for ever and a day.
Try running a loop ten times and have a sleep 600 in...
1,422
Posted By Yoda
You could count each execution and store it in a...
You could count each execution and store it in a file. Use this execution counter to decide whether to proceed or not:
if [ -f "/tmp/exec_counter_$(date +%Y%m%d)" ]
then
cnt=$( cat...
1,807
Posted By dinesh1178
mv $file /data/home/abc/xyz/azher/backup/`echo...
mv $file /data/home/abc/xyz/azher/backup/`echo $file|cut -d. -f1`_$now.csv
1,807
Posted By anbu23
mv "${file}"...
mv "${file}" /data/home/abc/xyz/azher/backup/"${file%.*}_$now.${file#*.}"
5,444
Posted By wisecracker
I am with Don here... There is no way of...
I am with Don here...

There is no way of knowing at any one point in time for any *.csv file that your last
split will always be 33. It surely must be the remainder.

There is the situation...
5,444
Posted By Don Cragun
And, how do the command line arguments in ./a.sh...
And, how do the command line arguments in ./a.sh 2 1000 5 relate to your original request to put 100 lines in one file and split the remaining lines in 1000 line chunks?
5,444
Posted By Don Cragun
You never answered Scrutinizer's question: Is...
You never answered Scrutinizer's question: Is this homework?

What shell are you using?

PS How do the command line arguments in ./a.sh 2 1000 5 relate to your original request to put 100 lines...
5,444
Posted By Scrutinizer
Do you mean what are the command line arguments...
Do you mean what are the command line arguments to split? Have a look at man split .
5,444
Posted By Scrutinizer
Hi, you cannot read and write to the same file at...
Hi, you cannot read and write to the same file at the same time like that.

Try something like:
{ n=0
while IFS= read -r line && [ $(( n+=1 )) -le 100 ]
do
printf "%s\n" "$line"
done...
5,444
Posted By Scrutinizer
For the remaining you can use split. Can you show...
For the remaining you can use split. Can you show us what you tried so far?
5,444
Posted By clx
While we always encourage here to show the...
While we always encourage here to show the efforts and at least start trying something. This is the way to learn and also it will give us the feeling that we are not doing your work instead we are...
5,444
Posted By Akshay Hegde
Show us your sample input and expected output.
Show us your sample input and expected output.
5,444
Posted By clx
Start with (always) looking at the man pages. ...
Start with (always) looking at the man pages.

man head
man tail
man split

By your luck, all the three man pages are very small (single page), and you can understand them very easily.
Please...
5,444
Posted By joeyg
There is a specific forum for 'emergency' or...
There is a specific forum for 'emergency' or quick requests.

What have you tried?
Showing results 1 to 25 of 26

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