You are not logged in.
here is the code
#!/bin/bash
file='/mnt/files/mysecondhome/Upkeep/Arch.Upkeep/Music/play3'
cat ${file} | \
while read name num
do
sum=$(($num + 1))
sed s/"$name $num/$name $sum"/g /mnt/files/mysecondhome/Upkeep/Arch.Upkeep/Music/playcount1 > /home/ryan/Upkeep/Music/play2
done
I took a sample from the non-test files and put it in the test files, and it works. I'm not really sure what to do now, thanks in advance for your help.
Offline
What are these files supposed to be?
You're constantly overwriting /home/ryan/Upkeep/Music/play2 with the single > redirect so only the last loop counts.
You probably want to copy playcount1 and then use sed -i on it.
Last edited by Procyon (2012-10-14 22:41:05)
Offline
right now i don't have it on a cron job since it doesn't work. once it works i was planning on moving play2 to playcount1
sample of playcount1 since its 930k:
ZZZZZmntZZZZZfilesZZZZZmysecondhomeZZZZZMusicZZZZZWallsYYYYYJJJJJfYYYYYJerichoZZZZZWithYYYYYDevilsYYYYYAmongstYYYYYUsYYYYYAllZZZZZWelcomeYYYYYHomeXXXXXmpCCCCC 0
ZZZZZmntZZZZZfilesZZZZZmysecondhomeZZZZZMusicZZZZZWallsYYYYYJJJJJfYYYYYJerichoZZZZZWithYYYYYDevilsYYYYYAmongstYYYYYUsYYYYYAllZZZZZWithYYYYYDevilsYYYYYAmongstYYYYYUsYYYYYAllXXXXXmpCCCCC 0
ZZZZZmntZZZZZfilesZZZZZmysecondhomeZZZZZMusicZZZZZWarZZZZZWhyYYYYYCan'tYYYYYWeYYYYYBeYYYYYFriendsVVVVVZZZZZLowYYYYYRiderXXXXXmpCCCCC 1
ZZZZZmntZZZZZfilesZZZZZmysecondhomeZZZZZMusicZZZZZWarpstoneZZZZZDaemonicYYYYYWarpfireZZZZZAYYYYYStrangeYYYYYWindYYYYYIsYYYYYWaillingYYYYYForYYYYYTheYYYYYDeadXXXXXmpCCCCC 0
ZZZZZmntZZZZZfilesZZZZZmysecondhomeZZZZZMusicZZZZZWarpstoneZZZZZDaemonicYYYYYWarpfireZZZZZBloodYYYYYPaintedYYYYYMountainXXXXXmpCCCCC 0
play3:
ZZZZZmntZZZZZfilesZZZZZmysecondhomeZZZZZMusicZZZZZWarZZZZZWhyYYYYYCan'tYYYYYWeYYYYYBeYYYYYFriendsVVVVVZZZZZLowYYYYYRiderXXXXXmpCCCCC 1
i wasn't sure if certain special caracters or numbers were messing it up so thats whats with the zs ys vs xs and cs. also -i doesn't help
Last edited by moofly (2012-10-14 22:58:00)
Offline
Are you trying to increase the count of all files with 1?
If so, you could use awk:
#!/bin/bash
file='/mnt/files/mysecondhome/Upkeep/Arch.Upkeep/Music/play3'
awk '{ print $1, $2+1 }' "$file" > /home/ryan/Upkeep/Music/play2
Offline
@moofly, your post does not specify what it is that you are trying to do. Therefore, at best, others can only tell you what your script does, and even this require some assumptions on the properties of the files you are trying to operate on.
I suggest that you clearly specify what it is you are trying to do. Also, you say that your script doesn't work on the non-test files. What do you mean by this? In what sense does your script fail? For example, does it generate garbage output? Does it fail to do anything? What happens?
- Good judgement comes from experience; experience comes from bad judgement. -- Mark Twain
- There's a remedy for everything but death. -- The wise fool, Sancho Panza
- The purpose of a system is what it does. -- Anthony Stafford Beer
Offline