Reputation: 287
I want to plot data.dat contained in 100 folders enumerated from 001 to 100.
So the command would be:
p for [i=001:100] i."/data.dat" w l not
but leading zeros are discarded and it cannot find the files except the last one. I have tried also with
p for [i in "`seq -w 001 100`"] i."/data.dat" w l not
which gives the error
warning: Cannot find or open file "001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086087088089090091092093094095096097098099100/data.dat"
No data in plot
so I am wondering if there's a smart way of plotting the data without doing this:
p for [i in "001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100"] i."/data.dat" w l not
Upvotes: 1
Views: 1134
Reputation: 91
You could use the format specifier of the "sprintf" function to cast the integer to a string of explicit format:
p for [i=1:100] sprintf("%03.0f/data.dat", i) w l not
Note the trailing 0 before the number of digits, which tells sprintf to explicitly write trailing zeros. This only seems to work when casting to a float, although I can't find a reason for that.
Upvotes: 2